protected Guid SaveFinalItemInDB(int flag) { //flag:0保存 3申请入网 CY.CSTS.Core.Business.UnitInfo unitInfo = new CY.CSTS.Core.Business.UnitInfo(); Guid DutyId = new Guid(); unitInfo.UnitName = tbTitle.Text; unitInfo.Alias = tbTitle.Text; unitInfo.UnitType = new Guid(ddlUnitType.SelectedValue); unitInfo.Ownership = tbOwnership.Text; unitInfo.DrtificialPerson = tbDrtificialPerson.Text; // 职务 if (ddlDutys.Text.Trim() != "") { List<CY.CSTS.Core.Business.Duty> postRankList = CY.CSTS.Core.Business.Duty.GetAllDuty() as List<CY.CSTS.Core.Business.Duty>; postRankList = postRankList.Where(Items => Items.Nmae == ddlDutys.Text.Trim()).ToList(); if (postRankList.Count == 0) { CY.CSTS.Core.Business.Duty post = new CY.CSTS.Core.Business.Duty(); post.Nmae = ddlDutys.Text.Trim(); post.Save(); DutyId = post.Id; } else { DutyId = postRankList[0].Id; } unitInfo.DrtificialPersonDutyID = DutyId; } unitInfo.LinkDepartdement = tbLinkDepartdement.Text; if (!string.IsNullOrEmpty(tbLinkMan.Text)) { unitInfo.Linkman = tbLinkMan.Text; if (!string.IsNullOrEmpty(ddlLinkManDuty.Text)) { // 职务 if (ddlLinkManDuty.Text.Trim() != "") { List<CY.CSTS.Core.Business.Duty> postRankList = CY.CSTS.Core.Business.Duty.GetAllDuty() as List<CY.CSTS.Core.Business.Duty>; postRankList = postRankList.Where(Items => Items.Nmae == ddlLinkManDuty.Text.Trim()).ToList(); if (postRankList.Count == 0) { CY.CSTS.Core.Business.Duty post = new CY.CSTS.Core.Business.Duty(); post.Nmae = ddlLinkManDuty.Text.Trim(); post.Save(); DutyId = post.Id; } else { DutyId = postRankList[0].Id; } unitInfo.LinkmanDutyID = DutyId; } } unitInfo.LinkmanTel = tbLinkmanTel.Text; } unitInfo.ChargeDepartMent = tbChargeDepartMent.Text; unitInfo.Synopsis = tbSynopsis.Text; unitInfo.InstrumentSection = tbInstrumentSection.Text; int Count = default(int); if (!string.IsNullOrEmpty(tbVindicatorCount.Text) && int.TryParse(tbVindicatorCount.Text, out Count)) { unitInfo.VindicatorCount = Count; } if (!string.IsNullOrEmpty(ddlSubjection.Text)) { unitInfo.Subjection = Convert.ToInt32(ddlSubjection.SelectedValue); } unitInfo.WorkCode = tbWorkCode.Text; unitInfo.Postalcode = tbZipCode.Text; unitInfo.Tel = tbTel.Text; unitInfo.Fax = tbFax.Text; unitInfo.Email = tbEmail.Text; if (!string.IsNullOrEmpty(ddlProvince.SelectedValue) && CY.Utility.Common.StringHelper.IsGuid(ddlProvince.SelectedValue.Trim())) { string TempName = ddlCity.ClientID.Replace("_","$"); unitInfo.ProvinceID = new Guid(ddlProvince.SelectedValue); if (Request.Form[TempName] != null && Request.Form[TempName] != "0") { unitInfo.CityID = new Guid(Request.Form.Get(TempName)); } } unitInfo.Address = tbAddress.Text; unitInfo.BankAccountName = tbBankAccountName.Text; unitInfo.BankName = tbBankName.Text; unitInfo.BankAccount = tbBankAccount.Text; unitInfo.Certificate = tbCertificate.Text; if (!string.IsNullOrEmpty(ddlTradeSort.SelectedValue) && CY.Utility.Common.StringHelper.IsGuid(ddlTradeSort.SelectedValue.Trim())) { unitInfo.TradeSortID = new Guid(ddlTradeSort.SelectedValue); } unitInfo.Website = tbWebSite.Text.Trim(); unitInfo.IsModification = Convert.ToInt32(ddlIsModification.SelectedValue); unitInfo.Rel_certificate = tbRel_certificate.Text; unitInfo.Operation = tbOperation.Text; unitInfo.Remark = tbRemark.Text; unitInfo.IsCooperantUnit = 1;//协作单位 unitInfo.AuditingState = flag; unitInfo.CreatDate = DateTime.Now; unitInfo.UpdateDate = DateTime.Now; unitInfo.UnitApplicationUserType = 1; CY.CSTS.Core.Business.User user = Session["User"] as CY.CSTS.Core.Business.User; int instructmentCount = default(int); if (!string.IsNullOrEmpty(tbInstructmentCount.Text) && int.TryParse(tbInstructmentCount.Text, out instructmentCount)) { unitInfo.InstrumentCount = instructmentCount; } if (user != null) { unitInfo.UnitInWorkPerson = user.Id; } unitInfo.Save(); return unitInfo.Id; }
private void SaveItemCommon(int flag) { bool IsSucess = false; #region Required Field if (string.IsNullOrEmpty(tbTitle.Text)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('单位名称不能为空!或已经存在该名称!')</script>"); return; } CY.CSTS.Core.Business.UnitType unittype = null; if (string.IsNullOrEmpty(ddlUnitType.SelectedValue) || ddlUnitType.SelectedValue == "0" || !CY.Utility.Common.StringHelper.IsGuid(ddlUnitType.SelectedValue.Trim()) || (unittype = CY.CSTS.Core.Business.UnitType.Load(new Guid(ddlUnitType.SelectedValue.Trim()))) == null) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('请选择单位类型!')</script>"); return; } if (string.IsNullOrEmpty(tbWorkCode.Text)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('组织机构代码不能为空!')</script>"); return; } if (string.IsNullOrEmpty(tbDrtificialPerson.Text)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('单位法人不能为空!')</script>"); return; } CY.CSTS.Core.Business.Duty duty = null; if (string.IsNullOrEmpty(ddlDutys.Text)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('法人职责不能为空!')</script>"); return; } if (string.IsNullOrEmpty(ddlSubjection.SelectedValue)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('上级单位不能为空!')</script>"); return; } if (string.IsNullOrEmpty(tbTel.Text)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('单位联系电话不能为空!')</script>"); return; } #region 执照注释 刘涛修改 //if (string.IsNullOrEmpty(tbCertificate.Text)) //{ // Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('单位执照不能为空!')</script>"); // return; //} #endregion #endregion #region Save Action try { object Id = FetchViewStateBag("Id"); if (Id != null && CY.Utility.Common.StringHelper.IsGuid(Id.ToString())) { CY.CSTS.Core.Business.UnitInfo unitInfo = CY.CSTS.Core.Business.UnitInfo.Load(new Guid(Id.ToString())); if (unitInfo != null) { unitInfo.UnitName = tbTitle.Text; unitInfo.Alias = tbTitle.Text; unitInfo.UnitType = new Guid(ddlUnitType.SelectedValue); unitInfo.Ownership = tbOwnership.Text; unitInfo.DrtificialPerson = tbDrtificialPerson.Text; Guid DutyId = new Guid(); // 职务 if (ddlDutys.Text.Trim() != "") { List<CY.CSTS.Core.Business.Duty> postRankList = CY.CSTS.Core.Business.Duty.GetAllDuty() as List<CY.CSTS.Core.Business.Duty>; postRankList = postRankList.Where(Items => Items.Nmae == ddlDutys.Text.Trim()).ToList(); if (postRankList.Count == 0) { CY.CSTS.Core.Business.Duty post = new CY.CSTS.Core.Business.Duty(); post.Nmae = ddlDutys.Text.Trim(); post.Save(); DutyId = post.Id; } else { DutyId = postRankList[0].Id; } unitInfo.DrtificialPersonDutyID = DutyId; } unitInfo.LinkDepartdement = tbLinkDepartdement.Text; if (!string.IsNullOrEmpty(tbLinkMan.Text)) { unitInfo.Linkman = tbLinkMan.Text; // 职务 if (ddlLinkManDuty.Text.Trim() != "") { List<CY.CSTS.Core.Business.Duty> postRankList = CY.CSTS.Core.Business.Duty.GetAllDuty() as List<CY.CSTS.Core.Business.Duty>; postRankList = postRankList.Where(Items => Items.Nmae == ddlLinkManDuty.Text.Trim()).ToList(); if (postRankList.Count == 0) { CY.CSTS.Core.Business.Duty post = new CY.CSTS.Core.Business.Duty(); post.Nmae = ddlLinkManDuty.Text.Trim(); post.Save(); DutyId = post.Id; } else { DutyId = postRankList[0].Id; } unitInfo.LinkmanDutyID = DutyId; } unitInfo.LinkmanTel = tbLinkmanTel.Text; } unitInfo.ChargeDepartMent = tbChargeDepartMent.Text; unitInfo.Synopsis = tbSynopsis.Text; unitInfo.InstrumentSection = tbInstrumentSection.Text; int Count = default(int); if (!string.IsNullOrEmpty(tbVindicatorCount.Text) && int.TryParse(tbVindicatorCount.Text, out Count)) { unitInfo.VindicatorCount = Count; } if (!string.IsNullOrEmpty(ddlSubjection.Text)) { unitInfo.Subjection = Convert.ToInt32(ddlSubjection.SelectedValue); } unitInfo.WorkCode = tbWorkCode.Text; unitInfo.Postalcode = tbZipCode.Text; unitInfo.Tel = tbTel.Text; unitInfo.Fax = tbFax.Text; unitInfo.Email = tbEmail.Text; if (!string.IsNullOrEmpty(ddlProvince.SelectedValue) && CY.Utility.Common.StringHelper.IsGuid(ddlProvince.SelectedValue.Trim())) { string TempName = ddlCity.ClientID.Replace("_", "$"); unitInfo.ProvinceID = new Guid(ddlProvince.SelectedValue); if (Request.Form[TempName] != null && Request.Form[TempName] != "0") { unitInfo.CityID = new Guid(Request.Form.Get(TempName)); } } unitInfo.Website = tbWebSite.Text.Trim(); unitInfo.Address = tbAddress.Text; unitInfo.BankAccountName = tbBankAccountName.Text; unitInfo.BankName = tbBankName.Text; unitInfo.BankAccount = tbBankAccount.Text; unitInfo.Certificate = tbCertificate.Text; if (!string.IsNullOrEmpty(ddlTradeSort.SelectedValue) && CY.Utility.Common.StringHelper.IsGuid(ddlTradeSort.SelectedValue.Trim())) { unitInfo.TradeSortID = new Guid(ddlTradeSort.SelectedValue); } unitInfo.IsModification = Convert.ToInt32(ddlIsModification.SelectedValue); unitInfo.Rel_certificate = tbRel_certificate.Text; unitInfo.Operation = tbOperation.Text; unitInfo.Remark = tbRemark.Text; unitInfo.UpdateDate = DateTime.Now; int instructmentCount = default(int); if (!string.IsNullOrEmpty(tbInstructmentCount.Text) && int.TryParse(tbInstructmentCount.Text, out instructmentCount)) { unitInfo.InstrumentCount = instructmentCount; } unitInfo.IsModification = int.Parse(ddlIsModification.SelectedValue); unitInfo.AuditingState = flag; //3;//申请审核 unitInfo.Save(); IsSucess = true; SaveImgs(unitInfo.Id); SaveFile(unitInfo.Id); if (IsSucess) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('修改单位信息成功!');window.location.href='UnitInNewWork.aspx';</script>"); } else { if (unitInfo.IsCooperantUnit == 1) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('修改单位信息失败!');window.location.href='UnitInNewWork.aspx';</script>"); } } } } } catch (Exception ex) { throw ex; } finally { } #endregion }
/// <summary> /// Not Need to Install Raltion Table /// </summary> public static void ImportDuty() { string strsql = "select distinct LEADDUTY from Unit "; ImportSqlServerUtility sql = new ImportSqlServerUtility(); DataSet ds = sql.ExecuteSqlDataSet(strsql); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { CY.CSTS.Core.Business.Duty duty = new CY.CSTS.Core.Business.Duty(); duty.Nmae = ds.Tables[0].Rows[i][0].ToString(); duty.Save(); } }
protected void btnSave_Click(object sender, EventArgs e) { this.NameErr.Visible = false; this.TypeErr.Visible = false; this.CodeErr.Visible = false; this.PersonErr.Visible = false; this.CertificateErr.Visible = false; this.DutyErr.Visible = false; this.SubjectionErr.Visible = false; this.lbLinkMan.Visible = false; this.lbLinkManDuty.Visible = false; this.lbLinkmanTel.Visible = false; bool IsSucess = false; bool full = true; #region Required Field if (string.IsNullOrEmpty(tbTitle.Text)) { this.NameErr.Text = "单位名称不能为空!或已经存在该名称!"; this.NameErr.Visible = true; full = false; } CY.CSTS.Core.Business.UnitType unittype = null; if (string.IsNullOrEmpty(ddlUnitType.SelectedValue) || ddlUnitType.SelectedValue == "0" || !CY.Utility.Common.StringHelper.IsGuid(ddlUnitType.SelectedValue.Trim()) || (unittype = CY.CSTS.Core.Business.UnitType.Load(new Guid(ddlUnitType.SelectedValue.Trim()))) == null) { this.TypeErr.Text = "请选择单位类型!"; this.TypeErr.Visible = true; full = false; } if (string.IsNullOrEmpty(tbWorkCode.Text)) { this.CodeErr.Text = "组织机构代码不能为空!"; this.CodeErr.Visible = true; full = false; } if (string.IsNullOrEmpty(tbDrtificialPerson.Text)) { this.PersonErr.Text = "单位法人不能为空!"; this.PersonErr.Visible = true; full = false; } CY.CSTS.Core.Business.Duty duty = null; if (string.IsNullOrEmpty(ddlDutys.Text.Trim())) { this.DutyErr.Text = "法人职责不能为空!"; this.DutyErr.Visible = true; full = false; } if (ddlSubjection.SelectedValue == "0") { this.SubjectionErr.Text = "上级单位不能为空!"; this.SubjectionErr.Visible = true; full = false; } if (string.IsNullOrEmpty(tbLinkMan.Text)) { this.lbLinkMan.Text = "资源共享联系人不能为空!"; this.lbLinkMan.Visible = true; full = false; } if (string.IsNullOrEmpty(ddlLinkManDuty.Text.Trim())) { this.lbLinkManDuty.Text = "资源共享联系人职务不能为空!"; this.lbLinkManDuty.Visible = true; full = false; } if (string.IsNullOrEmpty(tbLinkmanTel.Text)) { this.lbLinkmanTel.Text = "资源共享联系人电话不能为空!"; this.lbLinkmanTel.Visible = true; full = false; } //if (string.IsNullOrEmpty(tbCertificate.Text)) //{ // this.CertificateErr.Text = "单位执照不能为空!"; // this.CertificateErr.Visible = true; // full = false; //} if (!full) { return; } #endregion #region Save Action try { if (unitInfo != null) { unitInfo.UnitName = this.tbTitle.Text; unitInfo.Alias = this.tbAlias.Text; unitInfo.UnitType = new Guid(this.ddlUnitType.SelectedValue); unitInfo.Ownership = this.tbOwnership.Text; unitInfo.DrtificialPerson = this.tbDrtificialPerson.Text; Guid DutyId = new Guid(); // 职务 if (ddlDutys.Text.Trim() != "") { List<CY.CSTS.Core.Business.Duty> postRankList = CY.CSTS.Core.Business.Duty.GetAllDuty() as List<CY.CSTS.Core.Business.Duty>; postRankList = postRankList.Where(Items => Items.Nmae == ddlDutys.Text.Trim()).ToList(); if (postRankList.Count == 0) { CY.CSTS.Core.Business.Duty post = new CY.CSTS.Core.Business.Duty(); post.Nmae = ddlDutys.Text.Trim(); post.Save(); DutyId = post.Id; } else { DutyId = postRankList[0].Id; } unitInfo.DrtificialPersonDutyID = DutyId; } unitInfo.LinkDepartdement = this.tbLinkDepartdement.Text; if (!string.IsNullOrEmpty(this.tbLinkMan.Text)) { unitInfo.Linkman = this.tbLinkMan.Text; if (!string.IsNullOrEmpty(this.ddlLinkManDuty.Text) ) { // 职务 if (ddlLinkManDuty.Text.Trim() != "") { List<CY.CSTS.Core.Business.Duty> postRankList = CY.CSTS.Core.Business.Duty.GetAllDuty() as List<CY.CSTS.Core.Business.Duty>; postRankList = postRankList.Where(Items => Items.Nmae == ddlLinkManDuty.Text.Trim()).ToList(); if (postRankList.Count == 0) { CY.CSTS.Core.Business.Duty post = new CY.CSTS.Core.Business.Duty(); post.Nmae = ddlLinkManDuty.Text.Trim(); post.Save(); DutyId = post.Id; } else { DutyId = postRankList[0].Id; } unitInfo.LinkmanDutyID = DutyId; } } unitInfo.LinkmanTel = this.tbLinkmanTel.Text; } unitInfo.ChargeDepartMent = this.tbChargeDepartMent.Text; unitInfo.Synopsis = this.tbSynopsis.Text; unitInfo.InstrumentSection = this.tbInstrumentSection.Text; int Count = default(int); if (!string.IsNullOrEmpty(this.tbVindicatorCount.Text) && int.TryParse(this.tbVindicatorCount.Text, out Count)) { unitInfo.VindicatorCount = Count; } if (!string.IsNullOrEmpty(this.ddlSubjection.Text)) { unitInfo.Subjection = Convert.ToInt32(this.ddlSubjection.SelectedValue); } unitInfo.WorkCode = this.tbWorkCode.Text; unitInfo.Postalcode = this.tbZipCode.Text; unitInfo.Tel = this.tbTel.Text; unitInfo.Fax = this.tbFax.Text; unitInfo.Email = this.tbEmail.Text; if (!string.IsNullOrEmpty(this.ddlProvince.SelectedValue) && CY.Utility.Common.StringHelper.IsGuid(this.ddlProvince.SelectedValue.Trim())) { unitInfo.ProvinceID = new Guid(this.ddlProvince.SelectedValue); if (!string.IsNullOrEmpty(Request.Form.Get("ddlCity")) && CY.Utility.Common.StringHelper.IsGuid(this.ddlCity.SelectedValue.Trim())) { unitInfo.CityID = new Guid(Request.Form.Get("ddlCity")); } } unitInfo.Address = this.tbAddress.Text; unitInfo.BankAccountName = this.tbBankAccountName.Text; unitInfo.BankName = this.tbBankName.Text; unitInfo.BankAccount = this.tbBankAccount.Text; unitInfo.Certificate = this.tbCertificate.Text; if (!string.IsNullOrEmpty(this.ddlTradeSort.SelectedValue) && CY.Utility.Common.StringHelper.IsGuid(this.ddlTradeSort.SelectedValue.Trim())) { unitInfo.TradeSortID = new Guid(this.ddlTradeSort.SelectedValue); } unitInfo.IsModification = Convert.ToInt32(this.ddlIsModification.SelectedValue); unitInfo.Rel_certificate = this.tbRel_certificate.Text; unitInfo.Operation = this.tbOperation.Text; unitInfo.Remark = this.tbRemark.Text; if (!string.IsNullOrEmpty(Request.Form.Get("rdIsCheck"))) { unitInfo.AuditingState = Convert.ToInt32(Request.Form.Get("rdIsCheck")); DateTime createDate = DateTime.MinValue; DateTime auditDate = DateTime.MinValue; } unitInfo.UpdateDate = DateTime.Now; int instructmentCount = default(int); if (!string.IsNullOrEmpty(tbInstructmentCount.Text) && int.TryParse(this.tbInstructmentCount.Text, out instructmentCount)) { unitInfo.InstrumentCount = instructmentCount; } CY.CSTS.Core.Business.UnitInfo.update(unitInfo); IsSucess = true; CY.CSTS.Core.Business.FreshNews fresh = new CY.CSTS.Core.Business.FreshNews(); CY.CSTS.Core.Business.User user = Session["User"] as CY.CSTS.Core.Business.User; fresh.Sponsor = user.Name; fresh.Embracer = this.tbTitle.Text; fresh.UnitId = user.UnitID; fresh.EventTime = DateTime.Now; fresh.FreshEvent = "修改信息"; fresh.EventType = 2; SaveImgs(unitInfo.Id); SaveFile(unitInfo.Id); if (IsSucess) { if (unitInfo.IsCooperantUnit == 1) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('修改单位信息成功!');window.location.href='SubCenterDetail.aspx';</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('修改单位信息成功!');window.location.href='SubCenterDetail.aspx';</script>"); } } else { if (unitInfo.IsCooperantUnit == 1) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('修改单位信息失败!');window.location.href='SubCenterDetail.aspx';</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "<script type='text/javascript'>alert('修改单位信息失败!');window.location.href='SubCenterDetail.aspx';</script>"); } } } } catch (Exception ex) { throw ex; } finally { } #endregion }