本文整理匯總了C#中System.Data.DataTable.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.Equals方法的具體用法?C# DataTable.Equals怎麽用?C# DataTable.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.Equals方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InitDDL
/// <summary>
/// 將DataTable的數據綁定到DropDownList,
/// 當DataTable.Rows.Count != 1時,第一條記錄SelectValue = 0
/// </summary>
/// <param name="ddl">DropDownList 名稱</param>
/// <param name="dt">DataTable 名稱</param>
public static bool InitDDL(DropDownList ddl, DataTable dt, string DataTextField, string DataValueField, bool ShowSelectText)
{
if (dt.Equals(null) || dt.Rows.Count < 1)
{
ddl.Items.Clear();
ListItem li = new ListItem("NO DATA", "0");
ddl.Items.Insert(0, li);
ddl.Enabled = false;
}
else if (dt.Rows.Count == 1)
{
ddl.DataSource = dt;
ddl.DataTextField = DataTextField;
ddl.DataValueField = DataValueField;
ddl.DataBind();
ddl.Enabled = true;
}
else if (dt.Rows.Count > 1)
{
ddl.DataSource = dt;
ddl.DataTextField = DataTextField;
ddl.DataValueField = DataValueField;
ddl.DataBind();
if (ShowSelectText)
{
ListItem li = new ListItem("Please Select ...", "0");
ddl.Items.Insert(0, li);
}
ddl.Enabled = true;
}
//if (ddl.SelectedIndexChanged != null && !ddl.Items[0].Equals(new ListItem("Please Select ...", "0")))
//{
// ListItem li = new ListItem("Please Select ...", "0");
// ddl.Items.Insert(0, li);
//}
return ddl.Enabled;
}
示例2: GetTraceInfoFromHeader
///<summary>
///<para>Tạo thông tin vết từ Header</para>
///</summary>
/// <param name="Header"><para>Bảng lưu vết trong Header</para></param>
public void GetTraceInfoFromHeader(DataTable Header)
{
try
{
if (Header.Equals(null))
{
return;
}
//Read from Header Into Trace
Infor.ID = Utility.Int32Dbnull(Header.Rows[0]["ID"], 0);
Infor.BranchID = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["BranchID"]));
Infor.UserName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["UserName"]));
Infor.CreatedDate = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["CreatedDate"]));
Infor.IPAddress = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["IPAddress"]));
Infor.ComputerName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["ComputerName"]));
Infor.AccountName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["AccountName"]));
Infor.DLLName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["DLLName"]));
Infor.SubSystemName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["SubSystemName"]));
Infor.FunctionID = Utility.Int16Dbnull(Header.Rows[0]["FunctionID"]);
Infor.FunctionName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["FunctionName"]));
Infor.TableName = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["TableName"]));
Infor.Desc = Utility.CorrectStringValue(Utility.sDbnull(Header.Rows[0]["Desc"]));
Infor.LOT = Utility.Int16Dbnull(Header.Rows[0]["LOT"], 0);
}
catch (Exception ex)
{
Utility.ShowMsg("Lỗi khi lấy thông tin đối tượng lưu vết từ Header\n" + ex.Message);
return;
}
}
示例3: GetTraceObjectFromHeader
///<summary>
///<para>Lấy về đối tượng vết từ gói tin gửi từ Client lên Application Server: Header</para>
///</summary>
/// <param name="Header"><para>Bảng chứa thông tin vết. Thường là Header.Tables["Header"] <see cref="DataTable"/></para></param>
///<returns>HISTrace nếu tồn tại Header. Ngược lại trả về null.</returns>
public static TraceInfor GetTraceObjectFromHeader(DataTable Header)
{
TraceInfor trace = new TraceInfor();
try
{
if (Header.Equals(null))
{
//Utility.ShowMsg("Header bạn đưa vào chưa được khởi tạo nên chưa có thông tin về Trace. Đề nghị bạn xem lại...");
return null;
}
//Read from Header Into Trace
trace.pID = Int32Dbnull(Header.Rows[0]["ID"], 0);
trace.pBranchID = CorrectStringValue(sDbnull(Header.Rows[0]["BranchID"]));
trace.pUserName = CorrectStringValue(sDbnull(Header.Rows[0]["UserName"]));
trace.pCreatedDate = CorrectStringValue(sDbnull(Header.Rows[0]["CreatedDate"]));
trace.pIPAddress = CorrectStringValue(sDbnull(Header.Rows[0]["IPAddress"]));
trace.ComputerName = CorrectStringValue(sDbnull(Header.Rows[0]["ComputerName"]));
trace.AccountName = CorrectStringValue(sDbnull(Header.Rows[0]["AccountName"]));
trace.DLLName = CorrectStringValue(sDbnull(Header.Rows[0]["DLLName"]));
trace.pSubSystemName = CorrectStringValue(sDbnull(Header.Rows[0]["SubSystemName"]));
trace.pFunctionID = Int16Dbnull(Header.Rows[0]["FunctionID"]);
trace.FunctionName = CorrectStringValue(sDbnull(Header.Rows[0]["FunctionName"]));
trace.pTableName = CorrectStringValue(sDbnull(Header.Rows[0]["TableName"]));
trace.pDesc = CorrectStringValue(sDbnull(Header.Rows[0]["Desc"]));
trace.pLO = Int16Dbnull(Header.Rows[0]["LOT"], 0);
return trace;
}
catch (Exception ex)
{
Utility.ShowMsg("Lỗi khi lấy đối tượng vết từ Header:\n" + ex.Message);
return null;
}
}
示例4: MergeHeader
///<summary>
///<para>Gắn Header vào Entity để truyền lên BusinessLogic xử lý</para>
///</summary>
/// <param name="Entity"><para>Entity chứa thông tin nghiệp vụ</para></param>
/// <param name="Header"><para>Header chứa gói tin lưu vết và loại nghiệp vụ cần thao tác</para></param>
///<returns></returns>
public static void MergeHeader(ref DataSet Entity, DataTable Header)
{
try
{
if (Entity.Equals(null))
{
Utility.ShowMsg("Bạn phải khởi tạo Entity trước khi thực hiện hàm này");
return;
}
if (Header.Equals(null))
{
Utility.ShowMsg("Bạn phải khởi tạo Header trước khi thực hiện hàm này");
return;
}
if (Entity.Tables.Contains(Header.TableName))
{
Entity.Tables.Remove(Header.TableName);
Entity.AcceptChanges();
Entity.Merge(Header);
Entity.AcceptChanges();
}
else
{
Entity.Merge(Header);
Entity.AcceptChanges();
}
}
catch (Exception ex)
{
ShowMsg("Lỗi khi gắn Header vào Entity:\n" + ex.Message);
}
}
示例5: MergeTraceIntoHeader
///<summary>
///<para>Đưa giá trị của vết vào Header trước khi gửi lên Business xử lý</para>
///</summary>
/// <param name="Header"><para>Bảng lưu vết</para></param>
/// <param name="trace"><para>Đối tượng vết <see cref="HISTrace"/></para></param>
public void MergeTraceIntoHeader(ref DataTable Header, TraceInfor trace)
{
try
{
DataRow dr;
bool bExist = false;
if (Header.Equals(null))
{
Utility.ShowMsg("Không thể gắn Trace vào Header vì đối tượng Header bạn truyền vào chưa được khởi tạo. Đề nghị bạn xem lại...");
return;
}
if (Header.Rows.Count > 0)
{
dr = Header.Rows[0];
bExist = true;
}
else
{
bExist = false;
dr = Header.NewRow();
}
//Read from Header Into Trace
if (trace == null) return;
dr["ID"] = Utility.Int16Dbnull(trace.pID, 0);
dr["BranchID"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pBranchID));
dr["UserName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pUserName));
dr["CreatedDate"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pCreatedDate, DateTime.Now.ToShortDateString()));
dr["IPAddress"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pIPAddress));
dr["ComputerName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.ComputerName));
dr["AccountName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.AccountName));
dr["DLLName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.DLLName));
dr["SubSystemName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pSubSystemName));
dr["FunctionID"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pFunctionID));
dr["FunctionName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.FunctionName));
dr["TableName"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pTableName));
dr["Desc"] = Utility.CorrectStringValue(Utility.sDbnull(trace.pDesc));
dr["LOT"] = Utility.Int16Dbnull(trace.pLO, 0);
if (!bExist)
{
Header.Rows.Add(dr);
}
Header.AcceptChanges();
}
catch (Exception ex)
{
Utility.ShowMsg("Lỗi khi tạo gán thông tin Trace vào Header:\n" + ex.Message);
return;
}
}
示例6: CreateExcel
/// <summary>
/// 導出含標題樣式的Excel
/// </summary>
/// <param name="dt">數據表</param>
/// <param name="FileName">文件名</param>
public static void CreateExcel(DataTable dataTable, string FileName,StringBuilder title,string bodyTr,string bodyTd,StringBuilder end)
{
if (dataTable != null && !dataTable.Equals(null))
{
//////////body 數據部分
for (int i = 0; i < dataTable.Rows.Count; i++)
{
title.Append(bodyTr);
for (int j = 0; j < dataTable.Columns.Count; j++)
{
title.Append(bodyTd + dataTable.Rows[i][j].ToString() + "</td>");
}
title.Append("</tr>");
}
//////////////
title.Append(end.ToString());
HttpResponse resp = System.Web.HttpContext.Current.Response;
resp.ClearContent();
resp.ContentEncoding = System.Text.Encoding.Default;
resp.AppendHeader("Content-Disposition", "attachment;filename=" + FileName);
resp.ContentType = "application/excel";
resp.Write(title);
resp.End();
}
}
示例7: AcceptancePlan_TableRowChanged
void AcceptancePlan_TableRowChanged(DataTable dataTable, DataColumn currentColumn, DataRow currentRow)
{
if (dataTable.Equals(NomenclatureInfo))
{
if (currentColumn.Equals(NomenclatureCount) || currentColumn.Equals(NomenclaturePrice))
{
fillNomenclatureRowData(currentRow);
}
}
else if (dataTable.Equals(TareInfo))
{
if (currentColumn.Equals(TareCount) || currentColumn.Equals(TarePrice))
{
fillTareRowData(currentRow);
}
}
}
示例8: dataTableCopy
/// <summary>
/// 數據批量導入 DataTable方式寫入數據,resData源數據
/// </summary>
/// <param name="resData"></param>
/// <param name="server_Connect"></param>
/// <param name="desTable"></param>
public void dataTableCopy(DataTable resData, String desTable, ref string error)
{
error = "0";
if (resData == null || resData.Equals(null))
{
error = "源數據為空";
return;
}
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
SqlTransaction sqlbulkTransaction = conn.BeginTransaction();
////允許自增
SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(conn, SqlBulkCopyOptions.KeepIdentity, sqlbulkTransaction);
try
{
//請在插入數據的同時檢查約束,如果發生錯誤調用sqlbulkTransaction事務
sqlbulkcopy.DestinationTableName = desTable;//數據庫中的表名
for (int i = 0; i < resData.Columns.Count; i++)
{
//列映射
sqlbulkcopy.ColumnMappings.Add(resData.Columns[i].ColumnName, resData.Columns[i].ColumnName);
}
sqlbulkcopy.WriteToServer(resData);//源數據
sqlbulkTransaction.Commit();
sqlbulkcopy.Close();
}
catch (Exception ex)
{
sqlbulkTransaction.Rollback();
error = ex.ToString();
}
finally
{
//sqlbulkcopy.Close();
}
}
示例9: AcceptanceOfGoods_TableRowChanged
void AcceptanceOfGoods_TableRowChanged(DataTable dataTable, DataColumn currentColumn, DataRow currentRow)
{
if (dataTable.Equals(NomenclatureInfo))
{
if (currentColumn.Equals(Nomenclature))
{
fillTareInRow(currentRow);
}
else if (currentColumn.Equals(NomenclatureParty))
{
fillDateInRow(currentRow);
}
}
}
示例10: AcceptanceOfGoods_TableRowAdded
void AcceptanceOfGoods_TableRowAdded(DataTable dataTable, DataRow currentRow)
{
if (dataTable.Equals(NomenclatureInfo))
{
currentRow[NomenclatureCode] = newCodeNumber;
}
}