private void btn保存_Click(object sender, EventArgs e) { try { if (txtcVencode.Text.Trim() == "") { txtcVencode.Focus(); throw new Exception("供应商编码不能为空"); } if (txtcVenName.Text.Trim() == "") { txtcVenName.Focus(); throw new Exception("供应商名称不能为空"); } string sSQL = ""; if (sVenCode.Trim() != "") { sSQL = "select count(1) from @u8.Vendor where cVenCode = '" + txtcVencode.Text.Trim() + "'"; int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL)); if (iCou > 0) { throw new Exception("供应商编码不能与U8重复"); } } ArrayList aList = new ArrayList(); if (sVenCode.Trim() == "") { sSQL = " INSERT INTO [UFDLImport].[dbo].[VendorHC]([cVenCode] ,[cVenName] ,[cVenAbbName] ,[Address] ,[cVenPerson] " + ",[cVenPhone],[Remark1] ,[Remark2] ,[Remark3] " + ",[Remark4],[Remark5] ,[Remark6] ,[Remark7] ,[Remark8] ,[CreateUid] ,[CreateDate] ,[UpdateUid] ,[UpdateDate]) " + " VALUES " + "(N'" + txtcVencode.Text.Trim() + "' ,N'" + txtcVenName.Text.Trim() + "' ,N'" + txtcVenAbbName.Text.Trim() + "' ,N'" + txtAddress.Text.Trim() + "' ,N'" + txtcVenPerson.Text.Trim() + "'" + ",N'" + txtcVenPhone.Text.Trim() + "' ,N'" + txtRemark1.Text.Trim() + "' ,N'" + txtRemark2.Text.Trim() + "',N'" + txtRemark3.Text.Trim() + "',N'" + txtRemark4.Text.Trim() + "' " + ",N'" + txtRemark5.Text.Trim() + "' ,N'" + txtRemark6.Text.Trim() + "' ,N'" + txtRemark7.Text.Trim() + "' ,N'" + txtRemark8.Text.Trim() + "' ,N'" + FrameBaseFunction.ClsBaseDataInfo.sUserName + "' ,getdate() ,null,null) "; } else { sSQL = @" UPDATE [UFDLImport].[dbo].[VendorHC] " + "SET [cVenName] = N'" + txtcVenName.Text.Trim() + "' " + " ,[cVenAbbName] = N'" + txtcVenAbbName.Text.Trim() + "' " + " ,[Address] = N'" + txtAddress.Text.Trim() + "' " + " ,[cVenPerson] = N'" + txtcVenPerson.Text.Trim() + "' " + " ,[cVenPhone] = N'" + txtcVenPhone.Text.Trim() + "' " + " ,[Remark1] = N'" + txtRemark1.Text.Trim() + "' " + " ,[Remark2] = N'" + txtRemark2.Text.Trim() + "' " + " ,[Remark3] = N'" + txtRemark3.Text.Trim() + "' " + " ,[Remark4] = N'" + txtRemark4.Text.Trim() + "' " + " ,[Remark5] = N'" + txtRemark5.Text.Trim() + "' " + " ,[Remark6] = N'" + txtRemark6.Text.Trim() + "' " + " ,[Remark7] = N'" + txtRemark7.Text.Trim() + "' " + " ,[Remark8] = N'" + txtRemark8.Text.Trim() + "' " + " ,[UpdateUid] = N'" + FrameBaseFunction.ClsBaseDataInfo.sUserName + "' " + " ,[UpdateDate] = getdate() " + "where cVenCode = N'" + sVenCode.Trim() + "'"; } aList.Add(sSQL); if (aList.Count > 0) { clsSQLCommond.ExecSqlTran(aList); MessageBox.Show("保存成功"); SetEnable(false); btn保存.Enabled = false; } } catch (Exception ee) { MessageBox.Show(ee.Message); } }
private void btn保存_Click(object sender, EventArgs e) { try { try { gridView1.FocusedRowHandle -= 1; gridView1.FocusedRowHandle += 1; } catch { } if (txt主题.Text.Trim() == "") { txt主题.Focus(); throw new Exception("主题不能为空"); } if (richTextBox内容.Text.Trim() == "") { richTextBox内容.Focus(); throw new Exception("内容不能为空"); } if (sGuid == "") { sGuid = Guid.NewGuid().ToString(); } string sSQL = "select count(1) from UFDLImport..杜乐公告 where guid = '" + sGuid + "' and isnull(发布人,'') <> ''"; int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL)); if (iCou > 0) { throw new Exception("已经发布不能修改"); } ArrayList aList = new ArrayList(); sSQL = "delete UFDLImport..杜乐公告明细 where guid = '" + sGuid + "'"; aList.Add(sSQL); bool b = false; for (int i = 0; i < gridView1.RowCount; i++) { if (Convert.ToBoolean(gridView1.GetRowCellValue(i, gridCol选择))) { sSQL = "insert into UFDLImport..杜乐公告明细(供应商编码,guid)values('" + gridView1.GetRowCellValue(i, gridCol供应商编码).ToString().Trim() + "','" + sGuid + "')"; aList.Add(sSQL); b = true; } } if (!b) { throw new Exception("请选择供应商"); } sSQL = "select count(1) from UFDLImport..杜乐公告 where guid = '" + sGuid + "'"; iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL)); if (iCou == 0) { sSQL = "insert into UFDLImport..杜乐公告(标题,内容,制单人,制单日期,guid)values('" + txt主题.Text.Trim() + "','" + richTextBox内容.Text.Trim() + "','" + FrameBaseFunction.ClsBaseDataInfo.sUid + "','" + DateTime.Today.ToString("yyyy-MM-dd") + "','" + sGuid + "')"; aList.Add(sSQL); } else { sSQL = "update UFDLImport..杜乐公告 set 标题 = '" + txt主题.Text.Trim() + "',内容 = '" + richTextBox内容.Text.Trim() + "',制单人 = '" + FrameBaseFunction.ClsBaseDataInfo.sUid + "',制单日期 = '" + DateTime.Today.ToString("yyyy-MM-dd") + "' where guid = '" + sGuid + "'"; aList.Add(sSQL); } if (aList.Count > 1) { clsSQLCommond.ExecSqlTran(aList); MessageBox.Show("保存成功"); txt制单人.Text = FrameBaseFunction.ClsBaseDataInfo.sUid; date制单日期.Text = DateTime.Today.ToString("yyyy-MM-dd"); } } catch (Exception ee) { MessageBox.Show(ee.Message); } }
private void sSave() { try { try { gridView2.FocusedRowHandle -= 1; gridView2.FocusedRowHandle += 1; } catch { } string sErr = ""; for (int i = 0; i < gridView2.RowCount; i++) { string s自定义物料 = gridView2.GetRowCellValue(i, gridCol_自定义物料).ToString().Trim(); string scInvCode = gridView2.GetRowCellValue(i, gridCol_cInvCode).ToString().Trim(); decimal d数量 = ReturnObjectToDecimal(gridView2.GetRowCellValue(i, gridCol_数量), 6); for (int j = i + 1; j < gridView2.RowCount; j++) { string s自定义物料2 = gridView2.GetRowCellValue(j, gridCol_自定义物料).ToString().Trim(); string scInvCode2 = gridView2.GetRowCellValue(j, gridCol_cInvCode).ToString().Trim(); decimal d数量2 = ReturnObjectToDecimal(gridView2.GetRowCellValue(j, gridCol_数量), 6); if (i == j) { continue; } if (s自定义物料 == s自定义物料2 && s自定义物料 != "" && d数量 == d数量2) { sErr = sErr + "行" + (i + 1).ToString() + "与 行 " + (j + 1) + "自定义物料一样\n"; continue; } if (scInvCode == scInvCode2 && scInvCode != "" && d数量 == d数量2) { sErr = sErr + "行" + (i + 1).ToString() + "与 行 " + (j + 1) + "物料编码一样\n"; continue; } } if (scInvCode.Trim() != "") { string sInvName = gridView2.GetRowCellDisplayText(i, gridCol_cInvName).ToString().Trim(); if (sInvName.Trim() == "") { sErr = sErr + "行" + (i + 1).ToString() + "物料编码不正确\n"; continue; } } } if (sErr.Length > 0) { throw new Exception(sErr); } if (txt主题.Text.Trim() == "") { txt主题.Focus(); throw new Exception("主题不能为空"); } if (richTextBox备注.Text.Trim() == "") { richTextBox备注.Focus(); throw new Exception("备注不能为空"); } if (sGuid == "") { sGuid = Guid.NewGuid().ToString(); } DateTime d截止时间 = Convert.ToDateTime(dtm截止.DateTime.ToString("yyyy-MM-dd") + " " + lookUpEditTime.Text + ":00"); if (dtm截止.DateTime < dtm单据日期.DateTime || d截止时间 < DateTime.Now.AddHours(1)) { throw new Exception("单据截止时间必须大于当前时间至少一小时"); } string sSQL = "select count(1) from UFDLImport..询价单 where guid = '" + sGuid + "' and isnull(发布人,'') <> ''"; int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL)); if (iCou > 0) { throw new Exception("已经发布不能修改"); } ArrayList aList = new ArrayList(); sSQL = "delete UFDLImport..询价单物料列表 where guid = '" + sGuid + "'"; aList.Add(sSQL); bool b = false; for (int i = 0; i < gridView2.RowCount; i++) { string sInvCode = gridView2.GetRowCellValue(i, gridCol_cInvCode).ToString().Trim(); string sInvCode自定义 = gridView2.GetRowCellValue(i, gridCol_自定义物料).ToString().Trim(); if (sInvCode == "" && sInvCode自定义 == "") { sErr = sErr + "行 " + (i + 1).ToString() + " 物料编码不能为空\n"; continue; } if (sInvCode != "" && sInvCode自定义 != "") { sErr = sErr + "行 " + (i + 1).ToString() + " 物料编码,自定义物料不能同时存在\n"; continue; } b = true; sSQL = @" insert into UFDLImport..询价单物料列表(GUID, 自定义物料,物料编码, 数量, 送样周期, 备注1, 备注2, 备注3, GUID物料) values('1111',2222,3333,4444,5555,'6666','7777','8888','9999') "; sSQL = sSQL.Replace("1111", sGuid); if (sInvCode自定义 == "") { sInvCode自定义 = "null"; } else { sInvCode自定义 = "'" + sInvCode自定义 + "'"; } sSQL = sSQL.Replace("2222", sInvCode自定义); if (sInvCode == "") { sInvCode = "null"; } else { sInvCode = "'" + sInvCode + "'"; } sSQL = sSQL.Replace("3333", sInvCode); decimal dQty = ReturnObjectToDecimal(gridView2.GetRowCellValue(i, gridCol_数量), 4); if (dQty < 0) { sErr = sErr + "行 " + (i + 1).ToString() + " 数量不能为负数\n"; continue; } if (dQty > 0) { sSQL = sSQL.Replace("4444", dQty.ToString()); } else { sSQL = sSQL.Replace("4444", "null"); } decimal d送样周期 = ReturnObjectToDecimal(gridView2.GetRowCellValue(i, gridCol_送样周期), 4); if (d送样周期 < 0) { sErr = sErr + "行 " + (i + 1).ToString() + " 送样周期不能为负数\n"; continue; } if (dQty > 0) { sSQL = sSQL.Replace("5555", d送样周期.ToString()); } else { sSQL = sSQL.Replace("5555", "null"); } sSQL = sSQL.Replace("6666", gridView2.GetRowCellValue(i, gridCol_备注1).ToString().Trim()); sSQL = sSQL.Replace("7777", gridView2.GetRowCellValue(i, gridCol_备注2).ToString().Trim()); sSQL = sSQL.Replace("8888", gridView2.GetRowCellValue(i, gridCol_备注3).ToString().Trim()); string sGuid物料 = gridView2.GetRowCellValue(i, gridCol_GUID物料).ToString().Trim(); if (sGuid物料.Length == 0) { sGuid物料 = Guid.NewGuid().ToString(); } sSQL = sSQL.Replace("9999", sGuid物料); aList.Add(sSQL); } if (!b) { throw new Exception("请设置物料"); } sSQL = "delete UFDLImport..询价单供应商 where guid = '" + sGuid + "'"; aList.Add(sSQL); b = false; if (label供应商.Text.Trim() == "") { throw new Exception("请选择供应商"); } string[] s供应商 = label供应商.Text.Trim().Split(','); for (int i = 0; i < s供应商.Length; i++) { sSQL = "insert into UFDLImport..询价单供应商(供应商编码,guid)values('" + s供应商[i].Trim() + "','" + sGuid + "')"; aList.Add(sSQL); b = true; } if (!b) { throw new Exception("请选择供应商"); } sSQL = "select count(1) from UFDLImport..询价单 where guid = '" + sGuid + "'"; iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL)); if (iCou == 0) { sSQL = "insert into UFDLImport..询价单(标题,备注,制单人,制单日期,单据日期,截止日期,guid,部门)values('" + txt主题.Text.Trim() + "','" + richTextBox备注.Text.Trim() + "','" + FrameBaseFunction.ClsBaseDataInfo.sUid + "','" + DateTime.Today.ToString("yyyy-MM-dd") + "','" + dtm单据日期.DateTime.ToString("yyyy-MM-dd") + "','" + dtm截止.DateTime.ToString("yyyy-MM-dd") + " " + lookUpEditTime.Text.Trim() + "','" + sGuid + "','" + sDepCode + "')"; aList.Add(sSQL); } else { sSQL = "update UFDLImport..询价单 set 截止日期 = '" + dtm截止.DateTime.ToString("yyyy-MM-dd") + " " + lookUpEditTime.Text.Trim() + "',标题 = '" + txt主题.Text.Trim() + "',备注 = '" + richTextBox备注.Text.Trim() + "',制单人 = '" + FrameBaseFunction.ClsBaseDataInfo.sUid + "',制单日期 = '" + DateTime.Today.ToString("yyyy-MM-dd") + "' where guid = '" + sGuid + "'"; aList.Add(sSQL); } if (sErr.Length > 0) { throw new Exception(sErr); } if (aList.Count > 1) { clsSQLCommond.ExecSqlTran(aList); sErr = ""; for (int i = 0; i < gridView2.RowCount; i++) { try { string sFile = ""; try { sFile = gridView2.GetRowCellValue(i, gridCol_上传附件).ToString().Trim(); } catch { } if (sFile != "") { string sGUID物料 = gridView2.GetRowCellValue(i, gridCol_GUID物料).ToString().Trim(); bool b上传 = 附件(sFile, sGUID物料); if (!b上传) { throw new Exception(""); } } } catch (Exception ee) { sErr = sErr + "行" + (i + 1).ToString() + "上传附件失败\n"; } } MessageBox.Show("保存成功"); if (sErr.Length > 0) { MessageBox.Show(sErr, "上传附件失败"); } SetValue(); } } catch (Exception ee) { throw new Exception(ee.Message); } }
private void btn保存_Click(object sender, EventArgs e) { try { if (txtcInvcode.Text.Trim() == "") { txtcInvcode.Focus(); throw new Exception("存货编码不能为空"); } if (txtcInvName.Text.Trim() == "") { txtcInvName.Focus(); throw new Exception("存货名称不能为空"); } if (lookUpEditInvcodeClassHC.Text.Trim() == "") { txtcInvName.Focus(); throw new Exception("存货分类不能为空"); } string sSQL = ""; if (scInvCode.Trim() != "") { sSQL = "select count(1) from @u8.Inventory where cInvCode = '" + txtcInvcode.Text.Trim() + "'"; int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL)); if (iCou > 0) { throw new Exception("供应商编码不能与U8重复"); } } ArrayList aList = new ArrayList(); if (scInvCode.Trim() == "") { sSQL = " INSERT INTO [UFDLImport].[dbo].[InventoryHC]([cInvCode] ,[cInvName] ,[cInvAbbName] ,[cInvStd] " + ",[Remark1] ,[Remark2] ,[Remark3] " + ",[Remark4],[Remark5] ,[Remark6] ,[Remark7] ,[Remark8] ,[CreateUid] ,[CreateDate] ,[UpdateUid] ,[UpdateDate],cInvCCode) " + " VALUES " + "(N'" + txtcInvcode.Text.Trim() + "' ,N'" + txtcInvName.Text.Trim() + "' ,N'" + txtcInvAbbName.Text.Trim() + "' ,N'" + txtcInvStd.Text.Trim() + "'" + ",N'" + txtRemark1.Text.Trim() + "' ,N'" + lookUpEditcVenCode.Text.Trim() + "',N'" + txtRemark3.Text.Trim() + "',N'" + txtRemark4.Text.Trim() + "' " + ",N'" + txtRemark5.Text.Trim() + "' ,N'" + txtRemark6.Text.Trim() + "' ,N'" + txtRemark7.Text.Trim() + "' ,N'" + txtRemark8.Text.Trim() + "' ,N'" + FrameBaseFunction.ClsBaseDataInfo.sUserName + "' ,getdate() ,null,null,'" + lookUpEditInvcodeClassHC.EditValue.ToString().Trim() + "') "; } else { sSQL = @" UPDATE [UFDLImport].[dbo].[InventoryHC] " + "SET [cInvName] = N'" + txtcInvName.Text.Trim() + "' " + " ,[cInvAbbName] = N'" + txtcInvAbbName.Text.Trim() + "' " + " ,[cInvStd] = N'" + txtcInvStd.Text.Trim() + "' " + " ,[cInvCCode] = '" + lookUpEditInvcodeClassHC.EditValue.ToString().Trim() + "' " + " ,[Remark1] = N'" + txtRemark1.Text.Trim() + "' " + " ,[Remark2] = N'" + lookUpEditcVenCode.Text.Trim() + "' " + " ,[Remark3] = N'" + txtRemark3.Text.Trim() + "' " + " ,[Remark4] = N'" + txtRemark4.Text.Trim() + "' " + " ,[Remark5] = N'" + txtRemark5.Text.Trim() + "' " + " ,[Remark6] = N'" + txtRemark6.Text.Trim() + "' " + " ,[Remark7] = N'" + txtRemark7.Text.Trim() + "' " + " ,[Remark8] = N'" + txtRemark8.Text.Trim() + "' " + " ,[UpdateUid] = N'" + FrameBaseFunction.ClsBaseDataInfo.sUserName + "' " + " ,[UpdateDate] = getdate() " + "where cInvCode = N'" + scInvCode.Trim() + "'"; } aList.Add(sSQL); if (aList.Count > 0) { clsSQLCommond.ExecSqlTran(aList); MessageBox.Show("保存成功"); SetEnable(false); btn保存.Enabled = false; SetNull(); btn保存.Enabled = true; SetEnable(true); scInvCode = ""; txtcInvcode.Focus(); } } catch (Exception ee) { MessageBox.Show(ee.Message); } }