|
|
|
แก้ให้เป็นทศนิยม 2 ตำแหน่ง ทำยังไครับ ท่านไหนทราบช่วยอธิบายให้ด้วยครับ |
|
|
|
|
|
|
|
ที่<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function formatCurrency(num)
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
</script>
...................
.............................
</HEAD>
<BODY>
.....
ส่วนที่จะใช้ค่ะ
<input type=text name=input2 size=10 onBlur="this.value=formatCurrency(this.value);">
....
</BODY>
ประมาณนี้ค่ะ น่าจะใช่นะ ^^
|
|
|
|
|
Date :
2011-10-07 17:44:22 |
By :
por_punggo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
int d = 1500.2000
string s = d.ToString("#,###.00"); // จะได้ 1,500.20
|
|
|
|
|
Date :
2011-10-08 01:50:45 |
By :
SPIRITT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณท่าน por และท่าน SPIRITT มากๆครับ
เด๋วยังไงจะไปลองดูครับ
|
|
|
|
|
Date :
2011-10-08 22:46:20 |
By :
pooshi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 2 เขียนโดย : SPIRITT เมื่อวันที่ 2011-10-08 01:50:45
รายละเอียดของการตอบ ::
รบกวนช่วยดูให้ด้วยครับ ว่าต้องใส่ตรงไหน พอดีผมทำไปแล้วมันก็ไม่เปลี่ยนหนะครับ
รบกวนช่วยแก้ให้ดูด้วยครับ
ขอบคุณครับ
Code (C#)
using System;
using System.Data;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WACSsystem.App_Codes
{
public class ClassPCCase
{
ClassConnection _Connection = new ClassConnection();
System.Data.SqlClient.SqlCommand MyCommand = new System.Data.SqlClient.SqlCommand();
ClassSearchSQL _ClassSearchSQL = new ClassSearchSQL();
VarPCCase _VarPCCase = new VarPCCase();
public DataTable getMainboardTOGridview(string commandGV)
{
switch (commandGV)
{
case "Add":
{
return _ClassSearchSQL.SearchSQLdata("select distinct mainboard_case_type as 'ชนิดเคส' from tb_pc_mainboard");
}
case "View":
{
return _ClassSearchSQL.SearchSQLdata("select distinct tb_pc_mainboard.mainboard_case_type as 'ชนิดเคส' from tb_sup_case,tb_pc_mainboard WHERE tb_pc_mainboard.mainboard_id = tb_sup_case.mainboard_id and tb_sup_case.case_id =" + _VarPCCase.LoadSelectItemPCCase["case_id"].ToString());
}
default: { return null; }
}
}
public bool AddCase2(
string s_picture,
string s_brand,
string s_model,
string s_price,
string s_dimension,
string s_material,
string s_class)
{
try
{
if (AddNewItem("insert into tb_pc_case(case_picture,case_brand,case_model,case_price,case_dimension,case_material,case_class,case_date) values ('" + s_picture + "','" + s_brand + "','" + s_model + "'," + s_price + ",'" + s_dimension + "','" + s_material + "','" + s_class + "',GETDATE())"))
{
DataRow DrowsearchCase = _ClassSearchSQL.SearchSQLdata("select case_id from tb_pc_case ORDER BY case_id DESC").Rows[0];
#region Mainboard
foreach (string searchItem in _VarPCCase.LoadAEMainboardSelect)
{
DataTable Dtableselect = _ClassSearchSQL.SearchSQLdata("select mainboard_id from tb_pc_mainboard where mainboard_case_type like '%" + searchItem + "%'");
for (int j = 0; j < Dtableselect.Rows.Count; j++)
{
DataRow Drowselect = Dtableselect.Rows[j];
if (AddNewItem("insert into tb_sup_case(case_id,mainboard_id) values (" + DrowsearchCase[0].ToString() + "," + Drowselect[0].ToString() + ")") == false)
{
return false;
}
}
}
#endregion
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
private bool AddNewItem(string codesqlcommand)
{
try
{
System.Data.SqlClient.SqlDataAdapter rssAdapter = new System.Data.SqlClient.SqlDataAdapter();
rssAdapter.SelectCommand = MyCommand;
MyCommand.CommandText = codesqlcommand;
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = _Connection.sqlConnection();
if (_Connection.gs_connecttoserver == true)
{
MyCommand.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
private bool DeteleOldItem(string codesqlcommand)
{
try
{
System.Data.SqlClient.SqlDataAdapter rssAdapter = new System.Data.SqlClient.SqlDataAdapter();
rssAdapter.SelectCommand = MyCommand;
MyCommand.CommandText = codesqlcommand;
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = _Connection.sqlConnection();
if (_Connection.gs_connecttoserver == true)
{
MyCommand.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
public bool DeleteCase2(string s_id)
{
bool checkresult = false;
bool[] result = new bool[2];
result[0] = DeteleOldItem("DELETE FROM tb_sup_case WHERE case_id = " + s_id);
result[1] = DeteleOldItem("DELETE FROM tb_pc_case WHERE case_id = " + s_id);
foreach (bool checkfalse in result)
{
if (checkfalse == false)
{
checkresult = false;
}
else
{
checkresult = true;
}
}
return checkresult;
}
public bool EditCase2(string s_id,
string s_picture,
string s_brand,
string s_model,
string s_price,
string s_dimension,
string s_material,
string s_class)
{
bool checkresult = false;
try
{
System.Data.SqlClient.SqlDataAdapter rssAdapter = new System.Data.SqlClient.SqlDataAdapter();
rssAdapter.SelectCommand = MyCommand;
MyCommand.CommandText = "Update tb_pc_case set case_picture='" + s_picture + "',case_brand='" + s_brand + "',case_model='" + s_model + "',case_price=" + s_price + ",case_dimension='" + s_dimension + "',case_material='" + s_material + "',case_class='" + s_class + "',case_date=GETDATE() WHERE case_id = " + s_id ;
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = _Connection.sqlConnection();
if (_Connection.gs_connecttoserver == true)
{
MyCommand.ExecuteNonQuery();
checkresult = true;
}
else
{
checkresult = false;
}
bool result = DeteleOldItem("DELETE FROM tb_sup_case WHERE case_id = " + s_id);
if (result & checkresult)
{
checkresult = true;
}
else
{
checkresult = false;
}
#region CPU
foreach (string searchItem in _VarPCCase.LoadAEMainboardSelect)
{
DataTable Dtableselect = _ClassSearchSQL.SearchSQLdata("select mainboard_id from tb_pc_mainboard where mainboard_case_type = '" + searchItem + "'");
for (int j = 0; j < Dtableselect.Rows.Count; j++)
{
DataRow Drowselect = Dtableselect.Rows[j];
if (AddNewItem("insert into tb_sup_case(case_id,mainboard_id) values (" + s_id + "," + Drowselect[0].ToString() + ")") == false)
{
return false;
}
}
}
#endregion
}
catch
{
checkresult = false;
}
return checkresult;
}
public bool AddCase(
string s_picture,
string s_brand,
string s_model,
string s_price,
string s_dimension,
string s_material ,
string s_type,
string s_class)
{
try
{
System.Data.SqlClient.SqlDataAdapter rssAdapter = new System.Data.SqlClient.SqlDataAdapter();
rssAdapter.SelectCommand = MyCommand;
MyCommand.CommandText = "insert into tb_pc_case(case_picture,case_brand,case_model,case_price,case_dimension,case_material,case_type,case_class) values ('" + s_picture + "','" + s_brand + "','" + s_model + "'," + s_price + ",'" + s_dimension + "','" + s_material + "','" + s_type + "','" + s_class + "')";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = _Connection.sqlConnection();
if (_Connection.gs_connecttoserver == true)
{
MyCommand.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
public bool EditCase(string s_id,
string s_picture,
string s_brand,
string s_model,
string s_price,
string s_dimension,
string s_material,
string s_type,
string s_class)
{
try
{
System.Data.SqlClient.SqlDataAdapter rssAdapter = new System.Data.SqlClient.SqlDataAdapter();
rssAdapter.SelectCommand = MyCommand;
MyCommand.CommandText = "Update tb_pc_case set case_picture='" + s_picture + "',case_brand='" + s_brand + "',case_model='" + s_model + "',case_price=" + s_price + ",case_dimension='" + s_dimension + "',case_material='" + s_material + "',case_type='" + s_type + "',case_class='" + s_class + "' WHERE case_id ='" + s_id + "'";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = _Connection.sqlConnection();
if (_Connection.gs_connecttoserver == true)
{
MyCommand.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
public bool DeleteCase(string s_id)
{
try
{
System.Data.SqlClient.SqlDataAdapter rssAdapter = new System.Data.SqlClient.SqlDataAdapter();
rssAdapter.SelectCommand = MyCommand;
MyCommand.CommandText = "DELETE FROM tb_pc_case WHERE case_id =" + s_id;
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = _Connection.sqlConnection();
if (_Connection.gs_connecttoserver == true)
{
MyCommand.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
}
}
|
|
|
|
|
Date :
2011-10-10 22:30:06 |
By :
pooshi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try...
Code (C#)
float num = 2434.354358f;
Console.WriteLine("{0:n}" , num);
Console.ReadLine();
// Display 2,434.35
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#NFormatString
|
|
|
|
|
Date :
2011-10-11 00:47:33 |
By :
don move |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|