C#經驗總結

一..net,方法
1.       DataTable:    
①       DataTable.DataSet:    表所屬的 DataSet
注:返回的是一個DataSet
2.       DataSet:    DataSet中包含若干個DataTable
①       Clone:     DataSet 構,包括所有 DataTable 架構、系和束。不要制任何數據
②       Table:    取包含在 DataSet 中的表的集合。
③       取原始
MessageBox.Show(hanbaiRow[0, DataRowVersion.Original]);
MessageBox.Show(hanbaiRow[0, DataRowVersion. Current]);
hanbaiRow.EndEdit();是將Proposed值變爲Current
hanbaiRow.HanbaiNo = “1”; 得到的是Current
3.       DataAccess
①       出力パラメータ
iCommand.Parameters["@HakkoNo"].Direction= ParameterDirection.Output;
4.       ComboBox
①       DataSource:    取或置此 ListControl 的數據源。
5.       MessageBox.Show();            對話
6.       日期
①       日期
System.DateTime.Now.ToLongDateString()
System.DateTime.Now.ToString("yyyy'/'MM'/'dd");
②       日期轉換成字符串:
System.IFormatProvider   fmt=new   System.Globalization.CultureInfo("en-US",   true); 
tb1.Text=(DateTime.Parse("06/16/04   08:14:04",fmt)).ToString("yyyy-MM-dd   hh:mm:ss");
或者
DateTime d1=Convert.ToDateTime("2003-01-01 18:20:01");
③       時間加減
DateTime currentTime = DateTime.Now;
DateTime oldTime = currentTime.AddMonths(-2);
④       大小
int compareflg = DateTime.Compare(DateTime1, DateTime2);
7.       數字
①       tdbgHanbaiList.Columns[4].NumberFormat = "#,##0.0";
②       Math.Round(Convert.ToDouble(3.545)+0.0001,2);
③       decimal
I.       加法:decimal.Add(d1, d2)
II.      減法:decimal. Subtract (d1, d2)
III.     乘法:decimal. Multiply (d1, d2)
IV.      除法:decimal. Divide (d1, d2)
V.       取整:decimal.Truncate(d)
8.       字符串
①       string.ToString().Substring(0, 3);
Substring0第一位
9.       
①       篩選視圖DataSet的正在被編輯DataRow
DsHanbaiDetail.HanbaiDetailRow hanbaiDetailRow =
(DsHanbaiDetail.HanbaiDetailRow)dsHanbaiDetail.HanbaiDetail.DefaultView[tdbgHanbaiList.Row].Row;
DefaultView[tdbgHanbaiList.Row]DataRowView
②       DataTable.Select
DataTable table = DataSet1.Tables["Orders"];
DataRow[] foundRows = table.Select("Date > '1/1/00'", "CompanyName DESC");
10.      控件動態賦值
#region button1_Click
private void button1_Click(object sender, System.EventArgs e)
{
         for(int i = 1; i <= 30; i++)
{
                 TextBox tb1 = FindTextBox("textBox" + i.ToString());
                 if(tb1 != null)
                 {
                          tb1.Text = "hello, boy";
                 }
         }
}
#endregion
#region FindTextBox
private TextBox FindTextBox(string sTextBoxName)
{
         foreach(Control a in Controls)
         {
                 TextBox tb = a as TextBox; 
                 if(tb==null)
                 {
                          continue;
                 }
                 else if(tb.Name == sTextBoxName)
                 {
                          return tb;
                 }
         }
         return null;
}
#endregion
 
二.COM3
1.       調用方法
①       wsTatemono.GetTatemono
DataSet賦值
參數:
I.       tatemonoNo         Param
II.      dsTatemono         DataSet
III.     SecurityManager.Log      出的log
②       ControlManager.LockControl
控件定,如果是button使button不能使用
參數:
I.       CboChitengunCD    型:Control; 
II.      False             型:布FalseTrue 
③       control. DataBindings.Add(string, object, string)
機能:控件取數據
參數:
I.       propertyName 控件屬性
II.      DataSet       數據集
III.     DataMember   字段名稱
例子:
imeTsushinran1.DataBindings.Add("Text", teikeiBunsho, "HanbaiBunsho1")
④       入力check(Br)
chkResult = !TestManager.IsBlank(hanbaiRow.imeCustomerNo);
if (!CheckManager.SetResult(dsCheck, chkRowNo, "CHK-002", chkResult)) return;
chkResultfalse
⑤       得到境的userId
DataSet dataSet = SecurityManager.Log;
string createUserId = dataSet.Tables[0].Rows[0].ItemArray[0].ToString();
ItemArray是數
或者
string createUserId = SecurityManager.userId;
⑥       check
if (!CheckManager.SetResult(dsCheck, chkRowNo, "CHK-013", chkResult)) return;
chkResult = false就包return
 
2.       方法
①       ChangeMode
控件的置(如是否可用)
②       SetBinding
將控件與數據(DataSet型)行幫定
③       GetData
wsTatemono.GetTatemono     WsTatemono.GetTatemono         
bfTatemonoR.GetTatemono          daTatemono.Get(裏面就是存儲過程)
數據全部存DsTatemonoDataSet)中
wsTatemono.GetTatemono
參數:
I.       tatemonoNo         Param
II.      dsTatemono         DataSet
三.SQLSever
1.       運行存儲過
exec 程名+空格+參數
例:exec SD_InsertTE_SeikyuRireki
'000100','1','1','0','123','0','1234','0','1234567890','0','2006/02/25','2006/06/30','green'
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章