本文整理汇总了C#中System.Machine.GetByPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:C# Machine.GetByPrimaryKey方法的具体用法?C# Machine.GetByPrimaryKey怎么用?C# Machine.GetByPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Machine
的用法示例。
在下文中一共展示了Machine.GetByPrimaryKey方法的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);
}
}