本文整理汇总了C#中Company.GetByPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:C# Company.GetByPrimaryKey方法的具体用法?C# Company.GetByPrimaryKey怎么用?C# Company.GetByPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company.GetByPrimaryKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnEdit_Click
protected void btnEdit_Click(object sender, EventArgs e)
{
try
{
Company fac = new Company();
btnDelete.Enabled = true;
int countChecked = 0;
CheckBox cb = new CheckBox();
string ID = "";
foreach (GridViewRow r in grdCompany.Rows)
{
cb = (CheckBox)r.Cells[0].FindControl("chk");
if (cb.Checked)
{
countChecked++;
if (countChecked == 2) break;
else
{
ID = Common.GetRowString(r.Cells[1].Text);
}
}
}
if (countChecked == 0)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), GetResource("MSG_NONE_SELECTED_ITEM")) + "\");");
return;
}
else if (countChecked == 2)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), GetResource("MSG_MORE_ONE_SELECTED")) + "\");");
return;
}
else
{
panelEdit.Visible = true;
panelMain.Visible = false;
txtCompanyID.Text = ID;
txtCompanyID.Enabled = false;
//show detail in here
Company comp = new Company();
comp.CompanyId = int.Parse(txtCompanyID.Text);
comp = comp.GetByPrimaryKey();
txtName.Text = comp.CompanyName;
txtAddress1.Text = comp.Address1;
txtAddress2.Text = comp.Address2;
txtTEL.Text = comp.TEL;
txtFAX.Text = comp.FAX;
}
}
catch (Exception ex)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), ex.Message) + "\");");
logger.Error("Erorr btnEdit_click",ex);
}
}
示例2: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
if (btnDelete.Enabled == false)
{
List<Company> listComp = new List<Company>();
listComp = Company.GetAll().Where(l => l.CompanyName.Trim().ToLower() == txtName.Text.Trim().ToLower()).ToList();
if (listComp.Count > 0)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), string.Format(GetResource("CheckName"), lblCompanyName.Text)) + "\");");
return;
}
Company comp = new Company();
comp.CompanyId = Convert.ToInt32(txtCompanyID.Text);
comp.CompanyName = txtName.Text;
if(txtAddress1.Text != "")
comp.Address1 = txtAddress1.Text;
if (txtAddress2.Text != "")
comp.Address2 = txtAddress2.Text;
if (txtTEL.Text != "")
comp.TEL = txtTEL.Text;
if (txtFAX.Text != "")
comp.FAX = txtFAX.Text;
comp.isDeleted = false;
comp.CreateAccount = comp.ModifiedAccount = this.User.Identity.Name;
comp.Insert();
}
else
{
Company comp = new Company();
comp.CompanyId = int.Parse(txtCompanyID.Text);
comp = comp.GetByPrimaryKey();
if (comp.CompanyName.Trim() != txtName.Text.Trim())
{
List<Company> listComp = new List<Company>();
listComp = Company.GetAll().Where(l => l.CompanyName.Trim().ToLower() == txtName.Text.Trim().ToLower()).ToList();
if (listComp.Count > 0)
{
RegisterStartupScript("alert(\"" + GetJSMessage(GetResource("Title_Error"), string.Format(GetResource("CheckName"), lblCompanyName.Text)) + "\");");
return;
}
}
comp.ModifiedAccount = this.User.Identity.Name;
comp.CompanyId = int.Parse(txtCompanyID.Text);
comp.CompanyName = txtName.Text;
if (txtAddress1.Text != "")
comp.Address1 = txtAddress1.Text;
if (txtAddress2.Text != "")
comp.Address2 = txtAddress2.Text;
if (txtTEL.Text != "")
comp.TEL = txtTEL.Text;
if (txtFAX.Text != "")
comp.FAX = txtFAX.Text;
comp.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);
}
}