/// <summary> /// 新增公司信息 /// </summary> /// <param name="company">公司</param> public void AddCompany(Company company) { if (company == null) throw new ArgumentNullException("Company is null"); IUnitOfWork unitOfWork = _companyRepository.UnitOfWork; _companyRepository.Add(company); //complete changes in this unit of work unitOfWork.Commit(); }
/// <summary> /// 修改公司 /// </summary> /// <param name="company">公司</param> public void ModifyCompany(Company company) { if (company == null) throw new ArgumentNullException("Company is null"); IUnitOfWork unitOfWork = _companyRepository.UnitOfWork; _companyRepository.Modify(company); //complete changes in this unit of work unitOfWork.CommitAndRefreshChanges(); }
/// <summary> /// 页面控件赋值 /// </summary> /// <param name="Companycode">公司账号</param> protected void Storage(string Companycode) { company = _companyService.FindCompanyByCompanyCode(Companycode); if (company != null) { Txt_CompanyCode.Text = company.CompanyCode; Txt_FullName.Text = company.FullName; Txt_ShortName.Text = company.ShortName; Txt_Contactor.Text = company.Contactor; Txt_ContactorPhone.Text = company.ContactorPhone; Txt_Phone.Text = company.Phone; Txt_Fax.Text = company.Fax; Txt_Address.Text = company.Address; Txt_PostCode.Text = company.PostCode; Txt_OrganizationCode.Text = company.OrganizationCode; Txt_Remark.Text = company.Remark; DDL_Status.SelectedValue = company.Status.ToString(); Session["Company"] = company; } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_UpCompany_Click(object sender, EventArgs e) { bool ok = true; if (company == null) { if (Session["Company"] != null) { company = (Company)Session["Company"]; } else { company = _companyService.FindCompanyByCompanyCode(Request.QueryString["CompanyCode"].ToString()); } } if (Txt_CompanyCode.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入公司账号!')</script>"); Txt_CompanyCode.Focus(); ok = false; } else if (Txt_FullName.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入公司全称!')</script>"); Txt_FullName.Focus(); ok = false; } else if (Txt_ShortName.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入公司简称!')</script>"); Txt_ShortName.Focus(); ok = false; } else if (Txt_Contactor.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入联系人!')</script>"); ok = false; Txt_Contactor.Focus(); } else if (Txt_ContactorPhone.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入联系人电话!')</script>"); ok = false; Txt_ContactorPhone.Focus(); } else if (Txt_PostCode.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入邮政编码!')</script>"); ok = false; Txt_PostCode.Focus(); } else if (Txt_Address.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入地址!')</script>"); ok = false; Txt_Address.Focus(); } else if (Txt_Phone.Text.Trim() != "" && !RTel.IsMatch(Txt_Phone.Text.Trim())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入数字!')</script>"); ok = false; Txt_Phone.Focus(); } else if (!RTel.IsMatch(Txt_ContactorPhone.Text.Trim())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入数字!')</script>"); ok = false; Txt_ContactorPhone.Focus(); } else { if (ok == true) { company.FullName = Txt_FullName.Text.Trim().ToUpper(); company.ShortName = Txt_ShortName.Text.Trim().ToUpper(); company.Contactor = Txt_Contactor.Text.Trim().ToUpper(); company.ContactorPhone = Txt_ContactorPhone.Text.Trim(); company.Phone = Txt_Phone.Text.Trim(); company.Fax = Txt_Phone.Text.Trim(); company.Address = Txt_Address.Text.Trim(); company.PostCode = Txt_PostCode.Text.Trim(); company.OrganizationCode = Txt_OrganizationCode.Text.Trim(); company.Remark = Txt_Remark.Text.Trim(); company.Status = int.Parse(DDL_Status.SelectedValue); _companyService.ModifyCompany(company); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "show", "<script>alert('修改成功!');location='CompanyManagemnet.aspx'</script>"); } } }
private void FixupCompany(Company previousValue, bool skipKeys = false) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.Departments.Contains(this)) { previousValue.Departments.Remove(this); } if (Company != null) { if (!Company.Departments.Contains(this)) { Company.Departments.Add(this); } CID = Company.CID; } else if (!skipKeys) { CID = null; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("Company") && (ChangeTracker.OriginalValues["Company"] == Company)) { ChangeTracker.OriginalValues.Remove("Company"); } else { ChangeTracker.RecordOriginalValue("Company", previousValue); } if (Company != null && !Company.ChangeTracker.ChangeTrackingEnabled) { Company.StartTracking(); } } }
/// <summary> /// 新建公司账号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_AddCompany_Click(object sender, EventArgs e) { bool ok = true; if (Txt_CompanyCode.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入公司账号!')</script>"); Txt_CompanyCode.Focus(); ok = false; } else if (Txt_FullName.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入公司全称!')</script>"); Txt_FullName.Focus(); ok = false; } else if (Txt_ShortName.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入公司简称!')</script>"); Txt_ShortName.Focus(); ok = false; } else if (Txt_Contactor.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入联系人!')</script>"); ok = false; Txt_Contactor.Focus(); } else if (Txt_ContactorPhone.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入联系人电话!')</script>"); ok = false; Txt_ContactorPhone.Focus(); } else if (Txt_PostCode.Text.Trim()=="") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入邮政编码!')</script>"); ok = false; Txt_PostCode.Focus(); } else if (Txt_Address.Text.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入地址!')</script>"); ok = false; Txt_Address.Focus(); } else if (Txt_Phone.Text.Trim() != ""&&!RTel.IsMatch(Txt_Phone.Text.Trim())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('公司电话只能输入数字!')</script>"); ok = false; Txt_Phone.Focus(); } else if (!RTel.IsMatch(Txt_ContactorPhone.Text.Trim())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('联系人电话只能输入数字!')</script>"); ok = false; Txt_ContactorPhone.Focus(); } else { if (ok == true) { Company company = _companyService.FindCompanyByCompanyCode(Txt_CompanyCode.Text.Trim()); if (company != null) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该账号已存在,请重新输入!')</script>"); Txt_CompanyCode.Focus(); } else { company = new Company(); //addbook = new AddressBook(); company.CID = Guid.NewGuid(); company.CompanyCode = Txt_CompanyCode.Text.Trim().ToUpper(); company.FullName = Txt_FullName.Text.Trim().ToUpper(); company.ShortName = Txt_ShortName.Text.Trim().ToUpper(); company.Contactor = Txt_Contactor.Text.Trim().ToUpper(); company.ContactorPhone = Txt_ContactorPhone.Text.Trim(); company.Phone = Txt_Phone.Text.Trim(); company.Fax = Txt_Fax.Text.Trim(); company.Address = Txt_Address.Text.Trim(); company.PostCode = Txt_PostCode.Text.Trim(); company.OrganizationCode = Txt_OrganizationCode.Text.Trim(); company.Remark = Txt_Remark.Text.Trim(); company.Status = 1; _companyService.AddCompany(company); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('注册成功!')</script>"); InitialControl(this.Controls); } } } }