protected void btn_Save_Click(object sender, ImageClickEventArgs e) { if (ddlCollState.SelectedIndex == 0) { MessageBox.Show(this.upDepartAdd, this, "请选择煤矿状态"); return; } if (ddlCollProperty.SelectedIndex == 0) { MessageBox.Show(this.upDepartAdd, this, "请选择煤矿属性"); return; } if (strCustomer == "FuYuan") { if (this.ddlParcel.SelectedIndex == 0) { MessageBox.Show(this.upDepartAdd, this, "请选择片区"); return; } } //判断煤矿编号是否有重复 if (Request.QueryString["CollID"] == null) { if (DbHelperSQL.Exists("Select Count(0) from Sys_Colliery where CollName='" + this.txtCollName.Text.Trim().Replace("'", "''") + "'")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('煤矿名称已经存在,请重新输入!');", true); this.txtCollName.Focus(); return; } } else { //判断标示卡中是否存在该煤矿 //if (txtCollCode.Enabled != false) //{ if ("0" != bll.Getresult("count(*)", "Sys_Colliery", "CollCode !='" + Request.QueryString["CollID"].ToString() + "' and CollName='" + this.txtCollName.Text + "'")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('煤矿名称已经存在,请重新输入!');", true); return; } //} } #region 将煤矿信息存放到实体中 string strExtent = ".gif.png.jpg.bmp.psd.pcx"; // string CollCode = ""; //if (txtCollCode.Enabled != false) // CollCode = this.txtCollCode.Text; //else // CollCode = ViewState["CollCode"].ToString(); string CollName = this.txtCollName.Text; string OrgID = ddlOrgID.SelectedValue; string VillageCode = this.ddlVillageCode.SelectedValue; string MineOwner = this.txtMineOwner.Text; string MinePhone = this.txtMinePhone.Text; decimal YearOutput = decimal.Parse(this.txtYearOutput.Text); string CollState = this.ddlCollState.SelectedValue; string CollProperty = this.ddlCollProperty.SelectedValue;//煤矿属性 //税务企业工商营业执照 string ImageLicence = hidImageLicence.Value; // string LicenceImageType = this.txtLicenceImageType.Text; if (fupImageLicence.PostedFile.FileName != "") { string Licencepath = fupImageLicence.FileName; if (ImageLicence == "") { ImageLicence = Guid.NewGuid().ToString().Replace("-", ""); } string LicenceImageType = Licencepath.Substring(Licencepath.LastIndexOf(".") + 1);//后缀名 if (!strExtent.Contains("." + LicenceImageType.ToLower())) { MessageBox.Show(this.upDepartAdd, this, "税务企业工商营业执照只能为图片,请重新选择"); return; } } //税务登记证 string ImageRevenue = hidImageRevenue.Value; //string RevenueImageType = this.txtRevenueImageType.Text; if (fupImageRevenue.PostedFile.FileName != "") { string Revenuepath = fupImageRevenue.FileName; if (ImageRevenue == "") { ImageRevenue = Guid.NewGuid().ToString().Replace("-", ""); } string RevenueImageType = Revenuepath.Substring(Revenuepath.LastIndexOf(".") + 1);//后缀名 if (!strExtent.Contains("." + RevenueImageType.ToLower())) { MessageBox.Show(this.upDepartAdd, this, "税务登记证只能为图片,请重新选择"); return; } } //煤炭经营资格 string ImageCompetency = hidImageCompetency.Value; //string CompetencyImageType = this.txtCompetencyImageType.Text; if (fupImageCompetency.PostedFile.FileName != "") { string Competencypath = fupImageCompetency.FileName; if (ImageCompetency == "") { ImageCompetency = Guid.NewGuid().ToString().Replace("-", ""); } string CompetencyImageType = Competencypath.Substring(Competencypath.LastIndexOf(".") + 1);//后缀名 if (!strExtent.Contains("." + CompetencyImageType.ToLower())) { MessageBox.Show(this.upDepartAdd, this, "煤炭经营资格证只能为图片,请重新选择"); return; } } string Remark = this.txtRemark.Text; string IsForbid = this.ddlIsForbid.SelectedValue; //model.CollCode = CollCode; model.CollName = CollName; model.OrgCode = OrgID; model.VillageCode = VillageCode; model.MineOwner = MineOwner; model.MinePhone = MinePhone; model.YearOutput = YearOutput; model.CollState = CollState; model.CollProperty = CollProperty;//煤矿属性CollProperty model.ImageLicence = ImageLicence; model.ImageRevenue = ImageRevenue; model.ImageCompetency = ImageCompetency; model.Remark = Remark; model.IsForbid = IsForbid; if (strCustomer == "FuYuan") { model.ParcelCode = this.ddlParcel.SelectedValue; } else { model.ParcelCode = ""; } #endregion #region 将图片信息存放到实体中 //存储图片 List <IndustryPlatform.Model.Sys_FileSave> list = new List <IndustryPlatform.Model.Sys_FileSave>(); //税务企业工商营业执照 if (fupImageLicence.PostedFile.FileName != "") { file = new IndustryPlatform.Model.Sys_FileSave(); file.FileCode = ImageLicence; file.FileName = fupImageLicence.FileName; file.FileType = ""; file.FileContent = fupImageLicence.FileBytes; file.FilePath = ""; file.FileSize = 0; list.Add(file); } //税务登记证 if (fupImageRevenue.PostedFile.FileName != "") { file = new IndustryPlatform.Model.Sys_FileSave(); file.FileCode = ImageRevenue; file.FileName = fupImageRevenue.FileName; file.FileType = ""; file.FileContent = fupImageRevenue.FileBytes; file.FilePath = ""; file.FileSize = 0; list.Add(file); } //煤炭经营资格 if (fupImageCompetency.PostedFile.FileName != "") { file = new IndustryPlatform.Model.Sys_FileSave(); file.FileCode = ImageCompetency; file.FileName = fupImageCompetency.FileName; file.FileType = ""; file.FileContent = fupImageCompetency.FileBytes; file.FilePath = ""; file.FileSize = 0; list.Add(file); } #endregion if (Request.QueryString["CollID"] == null) { lock (this) { model.IsForbid = "0"; model.CollCode = DbHelperSQL.GetBaseMaxID("CollCode", "Sys_Colliery", "1=1"); if (bll.Add(model, list) == true) { #region 数据同步 try { //添加成功,数据同步到各个磅房 if (ConfigurationManager.AppSettings["IsSync"] == "1") { IndustryPlatform.DBUtility.MsmqManage msm = MsmqManage.GetMsmq(); string strSQL = "INSERT INTO Sys_Colliery ( " + "[CollCode] , " + "[CollName] , " + "[OrgCode] , " + "[VillageCode] , " + "[MineOwner] , " + "[MinePhone] , " + "[YearOutput] , " + "[CollState] , " + "[ImageLicence] , " + "[ImageRevenue] , " + "[ImageCompetency] , " + "[Remark] , " + "[CollProperty] , " + "[IsForbid],ParcelCode ) VALUES ('" + model.CollCode + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.CollName) + "','" + model.OrgCode + "','" + model.VillageCode + "','" + model.MineOwner + "','" + model.MinePhone + "'," + model.YearOutput + ",'" + model.CollState + "','" + model.ImageLicence + "','" + model.ImageRevenue + "','" + model.ImageCompetency + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.Remark) + "','" + model.CollProperty + "','" + model.IsForbid + "','" + model.ParcelCode + "') "; strSQL += ";insert into TT_ColieryAccount(CollCode) values ('" + model.CollCode + "')"; strSQL = msm.AllStation + msm.Prefix + "Sys_Colliery" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; msm.AddMsmq(strSQL); } //图片信息不用下发 //foreach (IndustryPlatform.Model.Sys_FileSave fileSave in list) //{ // strSQL = "INSERT INTO Sys_FileSave ( " + // "[FileCode] , " + // "[FileName] , " + // "[FilePath] , " + // "[FileSize] , " + // "[FileType] , " + // "[FileContent] ) VALUES ('" + fileSave.FileCode + "','" + fileSave.FileName + // "','" + fileSave.FilePath + "'," + fileSave.FileSize + // ",'" + fileSave.FileType + "','" + fileSave.FileContent + "')"; // strSQL = msm.AllStation + msm.Prefix + "Sys_FileSave" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; // msm.AddMsmq(strSQL); //} } catch { } #endregion ShowInfo(); ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加成功!');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加失败!');", true); } } } else { model.CollCode = Request.QueryString["CollID"].ToString(); if (bll.update(model, list) == true) { #region 数据同步 try { //添加成功,数据同步到各个磅房 if (ConfigurationManager.AppSettings["IsSync"] == "1") { IndustryPlatform.DBUtility.MsmqManage msm = IndustryPlatform.DBUtility.MsmqManage.GetMsmq(); string strSQL = "Delete From Sys_Colliery Where CollCode='" + model.CollCode + "';"; strSQL += "INSERT INTO Sys_Colliery ( " + "[CollCode] , " + "[CollName] , " + "[OrgCode] , " + "[VillageCode] , " + "[MineOwner] , " + "[MinePhone] , " + "[YearOutput] , " + "[CollState] , " + "[ImageLicence] , " + "[ImageRevenue] , " + "[ImageCompetency] , " + "[Remark] , " + "[CollProperty] , " + "[IsForbid],ParcelCode ) VALUES ('" + model.CollCode + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.CollName) + "','" + model.OrgCode + "','" + model.VillageCode + "','" + model.MineOwner + "','" + model.MinePhone + "'," + model.YearOutput + ",'" + model.CollState + "','" + model.ImageLicence + "','" + model.ImageRevenue + "','" + model.ImageCompetency + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.Remark) + "','" + model.CollProperty + "','" + model.IsForbid + "','" + model.ParcelCode + "') "; strSQL = msm.AllStation + msm.Prefix + "Sys_Colliery" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; msm.AddMsmq(strSQL); } //图片信息不用下发 //foreach (IndustryPlatform.Model.Sys_FileSave fileSave in list) //{ // strSQL = "INSERT INTO Sys_FileSave ( " + // "[FileCode] , " + // "[FileName] , " + // "[FilePath] , " + // "[FileSize] , " + // "[FileType] , " + // "[FileContent] ) VALUES ('" + fileSave.FileCode + "','" + fileSave.FileName + // "','" + fileSave.FilePath + "'," + fileSave.FileSize + // ",'" + fileSave.FileType + "','" + fileSave.FileContent + "')"; // strSQL = msm.AllStation + msm.Prefix + "Sys_FileSave" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; // msm.AddMsmq(strSQL); //} } catch { } #endregion ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "top.currForm.close();", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('修改失败!');", true); } } }
protected void btn_Save_Click(object sender, ImageClickEventArgs e) { if (ddlCollState.SelectedIndex == 0) { MessageBox.Show(this.upDepartAdd, this, "请选择煤矿状态"); return; } if (ddlCollProperty.SelectedIndex == 0) { MessageBox.Show(this.upDepartAdd,this,"请选择煤矿属性"); return; } if (strCustomer == "FuYuan") { if (this.ddlParcel.SelectedIndex == 0) { MessageBox.Show(this.upDepartAdd, this, "请选择片区"); return; } } //判断煤矿编号是否有重复 if (Request.QueryString["CollID"] == null) { if (DbHelperSQL.Exists("Select Count(0) from Sys_Colliery where CollName='"+this.txtCollName.Text.Trim().Replace("'","''")+"'")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('煤矿名称已经存在,请重新输入!');", true); this.txtCollName.Focus(); return; } } else { //判断标示卡中是否存在该煤矿 //if (txtCollCode.Enabled != false) //{ if ("0" != bll.Getresult("count(*)", "Sys_Colliery", "CollCode !='" + Request.QueryString["CollID"].ToString() + "' and CollName='" + this.txtCollName.Text + "'")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('煤矿名称已经存在,请重新输入!');", true); return; } //} } #region 将煤矿信息存放到实体中 string strExtent = ".gif.png.jpg.bmp.psd.pcx"; // string CollCode = ""; //if (txtCollCode.Enabled != false) // CollCode = this.txtCollCode.Text; //else // CollCode = ViewState["CollCode"].ToString(); string CollName = this.txtCollName.Text; string OrgID = ddlOrgID.SelectedValue; string VillageCode = this.ddlVillageCode.SelectedValue; string MineOwner = this.txtMineOwner.Text; string MinePhone = this.txtMinePhone.Text; decimal YearOutput = decimal.Parse(this.txtYearOutput.Text); string CollState = this.ddlCollState.SelectedValue; string CollProperty = this.ddlCollProperty.SelectedValue;//煤矿属性 //税务企业工商营业执照 string ImageLicence = hidImageLicence.Value; // string LicenceImageType = this.txtLicenceImageType.Text; if (fupImageLicence.PostedFile.FileName != "") { string Licencepath = fupImageLicence.FileName; if (ImageLicence == "") ImageLicence = Guid.NewGuid().ToString().Replace("-", ""); string LicenceImageType = Licencepath.Substring(Licencepath.LastIndexOf(".") + 1);//后缀名 if (!strExtent.Contains("." + LicenceImageType.ToLower())) { MessageBox.Show(this.upDepartAdd, this, "税务企业工商营业执照只能为图片,请重新选择"); return; } } //税务登记证 string ImageRevenue = hidImageRevenue.Value; //string RevenueImageType = this.txtRevenueImageType.Text; if (fupImageRevenue.PostedFile.FileName != "") { string Revenuepath = fupImageRevenue.FileName; if (ImageRevenue == "") ImageRevenue = Guid.NewGuid().ToString().Replace("-", ""); string RevenueImageType = Revenuepath.Substring(Revenuepath.LastIndexOf(".") + 1);//后缀名 if (!strExtent.Contains("." + RevenueImageType.ToLower())) { MessageBox.Show(this.upDepartAdd, this, "税务登记证只能为图片,请重新选择"); return; } } //煤炭经营资格 string ImageCompetency = hidImageCompetency.Value; //string CompetencyImageType = this.txtCompetencyImageType.Text; if (fupImageCompetency.PostedFile.FileName != "") { string Competencypath = fupImageCompetency.FileName; if (ImageCompetency == "") ImageCompetency = Guid.NewGuid().ToString().Replace("-", ""); string CompetencyImageType = Competencypath.Substring(Competencypath.LastIndexOf(".") + 1);//后缀名 if (!strExtent.Contains("." + CompetencyImageType.ToLower())) { MessageBox.Show(this.upDepartAdd, this, "煤炭经营资格证只能为图片,请重新选择"); return; } } string Remark = this.txtRemark.Text; string IsForbid = this.ddlIsForbid.SelectedValue; //model.CollCode = CollCode; model.CollName = CollName; model.OrgCode = OrgID; model.VillageCode = VillageCode; model.MineOwner = MineOwner; model.MinePhone = MinePhone; model.YearOutput = YearOutput; model.CollState = CollState; model.CollProperty = CollProperty;//煤矿属性CollProperty model.ImageLicence = ImageLicence; model.ImageRevenue = ImageRevenue; model.ImageCompetency = ImageCompetency; model.Remark = Remark; model.IsForbid = IsForbid; if (strCustomer == "FuYuan") model.ParcelCode = this.ddlParcel.SelectedValue; else model.ParcelCode = ""; #endregion #region 将图片信息存放到实体中 //存储图片 List<IndustryPlatform.Model.Sys_FileSave> list = new List<IndustryPlatform.Model.Sys_FileSave>(); //税务企业工商营业执照 if (fupImageLicence.PostedFile.FileName != "") { file = new IndustryPlatform.Model.Sys_FileSave(); file.FileCode = ImageLicence; file.FileName = fupImageLicence.FileName; file.FileType = ""; file.FileContent = fupImageLicence.FileBytes; file.FilePath = ""; file.FileSize = 0; list.Add(file); } //税务登记证 if (fupImageRevenue.PostedFile.FileName != "") { file = new IndustryPlatform.Model.Sys_FileSave(); file.FileCode = ImageRevenue; file.FileName = fupImageRevenue.FileName; file.FileType = ""; file.FileContent = fupImageRevenue.FileBytes; file.FilePath = ""; file.FileSize = 0; list.Add(file); } //煤炭经营资格 if (fupImageCompetency.PostedFile.FileName != "") { file = new IndustryPlatform.Model.Sys_FileSave(); file.FileCode = ImageCompetency; file.FileName = fupImageCompetency.FileName; file.FileType = ""; file.FileContent = fupImageCompetency.FileBytes; file.FilePath = ""; file.FileSize = 0; list.Add(file); } #endregion if (Request.QueryString["CollID"] == null) { lock(this) { model.IsForbid = "0"; model.CollCode = DbHelperSQL.GetBaseMaxID("CollCode", "Sys_Colliery", "1=1"); if (bll.Add(model, list) == true) { #region 数据同步 try { //添加成功,数据同步到各个磅房 if (ConfigurationManager.AppSettings["IsSync"] == "1") { IndustryPlatform.DBUtility.MsmqManage msm = MsmqManage.GetMsmq(); string strSQL = "INSERT INTO Sys_Colliery ( " + "[CollCode] , " + "[CollName] , " + "[OrgCode] , " + "[VillageCode] , " + "[MineOwner] , " + "[MinePhone] , " + "[YearOutput] , " + "[CollState] , " + "[ImageLicence] , " + "[ImageRevenue] , " + "[ImageCompetency] , " + "[Remark] , " + "[CollProperty] , " + "[IsForbid],ParcelCode ) VALUES ('" + model.CollCode + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.CollName) + "','" + model.OrgCode + "','" + model.VillageCode + "','" + model.MineOwner + "','" + model.MinePhone + "'," + model.YearOutput + ",'" + model.CollState + "','" + model.ImageLicence + "','" + model.ImageRevenue + "','" + model.ImageCompetency + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.Remark) + "','" + model.CollProperty + "','" + model.IsForbid + "','" + model.ParcelCode + "') "; strSQL += ";insert into TT_ColieryAccount(CollCode) values ('" + model.CollCode + "')"; strSQL = msm.AllStation + msm.Prefix + "Sys_Colliery" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; msm.AddMsmq(strSQL); } //图片信息不用下发 //foreach (IndustryPlatform.Model.Sys_FileSave fileSave in list) //{ // strSQL = "INSERT INTO Sys_FileSave ( " + // "[FileCode] , " + // "[FileName] , " + // "[FilePath] , " + // "[FileSize] , " + // "[FileType] , " + // "[FileContent] ) VALUES ('" + fileSave.FileCode + "','" + fileSave.FileName + // "','" + fileSave.FilePath + "'," + fileSave.FileSize + // ",'" + fileSave.FileType + "','" + fileSave.FileContent + "')"; // strSQL = msm.AllStation + msm.Prefix + "Sys_FileSave" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; // msm.AddMsmq(strSQL); //} } catch { } #endregion ShowInfo(); ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加成功!');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加失败!');", true); } } } else { model.CollCode =Request.QueryString["CollID"].ToString(); if (bll.update(model, list) == true) { #region 数据同步 try { //添加成功,数据同步到各个磅房 if (ConfigurationManager.AppSettings["IsSync"] == "1") { IndustryPlatform.DBUtility.MsmqManage msm = IndustryPlatform.DBUtility.MsmqManage.GetMsmq(); string strSQL = "Delete From Sys_Colliery Where CollCode='" + model.CollCode + "';"; strSQL += "INSERT INTO Sys_Colliery ( " + "[CollCode] , " + "[CollName] , " + "[OrgCode] , " + "[VillageCode] , " + "[MineOwner] , " + "[MinePhone] , " + "[YearOutput] , " + "[CollState] , " + "[ImageLicence] , " + "[ImageRevenue] , " + "[ImageCompetency] , " + "[Remark] , " + "[CollProperty] , " + "[IsForbid],ParcelCode ) VALUES ('" + model.CollCode + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.CollName) + "','" + model.OrgCode + "','" + model.VillageCode + "','" + model.MineOwner + "','" + model.MinePhone + "'," + model.YearOutput + ",'" + model.CollState + "','" + model.ImageLicence + "','" + model.ImageRevenue + "','" + model.ImageCompetency + "','" + IndustryPlatform.DBUtility.CommonMethod.RepChar(model.Remark) + "','" + model.CollProperty + "','" + model.IsForbid + "','" + model.ParcelCode + "') "; strSQL = msm.AllStation + msm.Prefix + "Sys_Colliery" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; msm.AddMsmq(strSQL); } //图片信息不用下发 //foreach (IndustryPlatform.Model.Sys_FileSave fileSave in list) //{ // strSQL = "INSERT INTO Sys_FileSave ( " + // "[FileCode] , " + // "[FileName] , " + // "[FilePath] , " + // "[FileSize] , " + // "[FileType] , " + // "[FileContent] ) VALUES ('" + fileSave.FileCode + "','" + fileSave.FileName + // "','" + fileSave.FilePath + "'," + fileSave.FileSize + // ",'" + fileSave.FileType + "','" + fileSave.FileContent + "')"; // strSQL = msm.AllStation + msm.Prefix + "Sys_FileSave" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; // msm.AddMsmq(strSQL); //} } catch { } #endregion ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "top.currForm.close();", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('修改失败!');", true); } } }