本文整理匯總了C#中System.Machine.Insert方法的典型用法代碼示例。如果您正苦於以下問題:C# Machine.Insert方法的具體用法?C# Machine.Insert怎麽用?C# Machine.Insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Machine
的用法示例。
在下文中一共展示了Machine.Insert方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
if (btnDelete.Enabled == false)
{
List<Machine> listMac = new List<Machine>();
listMac = Machine.GetAll().Where(l => l.Name.Trim().ToLower() == txtMachineName.Text.Trim().ToLower()).ToList();
if (listMac.Count > 0)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), string.Format(GetResource("CheckName"), lblMachineName.Text)) + "\");");
return;
}
Machine mac = new Machine();
mac.No = txtNo.Text;
mac.Name = txtMachineName.Text;
mac.CompanyId = int.Parse(GetCompany());
mac.FactoryId = int.Parse(cbxfactory.SelectedItem.Value);
mac.isDeleted = false;
mac.CreateAccount = mac.ModifiedAccount = this.User.Identity.Name;
mac.Insert();
}
else
{
Machine mac = new Machine();
mac.MachineId = int.Parse(hiddenMacID.Value);
mac = mac.GetByPrimaryKey();
if (mac.Name.Trim() != txtMachineName.Text.Trim())
{
List<Machine> listMac = new List<Machine>();
listMac = Machine.GetAll().Where(l => l.Name.Trim().ToLower() == txtMachineName.Text.Trim().ToLower()).ToList();
if (listMac.Count > 0)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), string.Format(GetResource("CheckName"), lblMachineName.Text)) + "\");");
return;
}
}
mac.ModifiedAccount = this.User.Identity.Name;
mac.No = txtNo.Text;
mac.Name = txtMachineName.Text;
mac.FactoryId = int.Parse(cbxfactory.SelectedItem.Value);
mac.CompanyId = int.Parse(GetCompany());
mac.Update();
}
panelEdit.Visible = false;
panelMain.Visible = true;
Search();
}
catch (Exception ex)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), ex.Message) + "\");");
logger.Error("Erorr btnSave_click", ex);
}
}