SM5604btnCGRK
using ClsPub; using Salien.Utility; using Salien.Utility.SUWF; using System; using System.Collections.Generic; using System.Data; using System.Web.UI.WebControls; using System.Collections; namespace SM5604btnCGRK { public class SM5604btnCGRK : ISuwfBus { private SlnSuwfPage _page; void ISuwfBus.Initial(SlnSuwfPage page) { _page = page; PUB.BindButtonEvent(_page, "btnCGRK", BtnCGRK_Click); } #region 采购入库 private void BtnCGRK_Click(object sender, EventArgs e) { string pks = _page.GetRowDataPrimaryKeys(); if (SlnString.IsNull(pks) == true) { _page.ShowMessage("没有选中网格"); return; } if( SlnDataAccess.GetDataTableCount( $"select id from sm_kc_ckrkb_tb where cgzbid in ({pks})")>0 ) { _page.ShowMessage("存在已经入库的采购记录"); return; } List<string> lstDJBH = new List<string>(); GridView grd = _page.MainGrid; string strMsg = ""; foreach (GridViewRow gridRow in grd.Rows) { if (_page.GridRowIsSelected(gridRow.RowIndex)) { if (_page.GetRowDataByKey(gridRow.RowIndex, "CKID") == "39")/*外购成品库*/ { continue; } if (_page.GetRowDataByKey(gridRow.RowIndex, "RKLB") == "9")/*红单*/ { continue; } if (ConvertFunction.ObjToDouble(_page.GetRowDataByKey(gridRow.RowIndex, "JE") )<1000.0) { continue; } if (_page.GetRowDataByKey(gridRow.RowIndex, "XTWLLBID") == "10")/*电化铝*/ { continue; } if (_page.GetRowDataByKey(gridRow.RowIndex, "WLID") == "79071")/*外购成品*/ { continue; } if ( ConvertFunction.ObjToDouble(_page.GetRowDataByKey(gridRow.RowIndex, "TPSL")) >0.0 ) { continue; } strMsg = strMsg + "第" + (gridRow.RowIndex + 1) + "行需要上传图片"; } } //如果包含“第”字样,说明有错误时间信息,则输出错误提示 if (strMsg.IndexOf("第") > -1) { _page.ShowMessage(strMsg); return; } foreach (GridViewRow gridRow in grd.Rows) { if (_page.GridRowIsSelected(gridRow.RowIndex)) { if (_page.GetRowDataByKey(gridRow.RowIndex, "ZT") == "0") { _page.ShowMessage($"第{gridRow.RowIndex + 1}行还没有登记无法做入库;"); return; } if (_page.GetRowDataByKey(gridRow.RowIndex, "ZT") == "2") { _page.ShowMessage($"第{gridRow.RowIndex + 1}行已经入库了不能再次做入库"); return; } if (_page.GetRowDataByKey(gridRow.RowIndex, "SSSL") == "0") { _page.ShowMessage($"第{gridRow.RowIndex + 1}行的入库数量为空不能提交,请录入入库数并点击保存按钮"); return; } AddUniqueDJBH(lstDJBH, _page.GetRowDataByKey(gridRow.RowIndex, "DJBH")); } } string sql = $@"insert into sm_kc_ckrkb_tb(id,WLID,SSSL,DDID,PCID,GYSID,CKMC,DJLX,CGZBID,DJ,JE,ZDSJ ,RKRQ,ZDR,CGY,ZTZD) select seqSM_KC_CKRKB.nextval,WLID,SSSL,SCDDMXID ,SCDDMXID,GYSID,CKID,RKLB,ID,JHDJ,JHDJ*SL,sysdate,sysdate,CZRID,CZRID,1 from SM_CG_CGZB_TB where id in ({pks})"; /*List<string> lstSql = new List<string>(); string[] arrPK = pks.Split(','); // 使用逗号作为分隔符分割字符串 foreach (string pk in arrPK) { lstSql.Add($@"insert into sm_kc_ckrkb_tb(id,WLID,SSSL,DDID,PCID,GYSID,CKMC,DJLX,CGZBID,DJ,JE,ZDSJ ,RKRQ,ZDR,CGY,ZTZD) select seqSM_KC_CKRKB.nextval,WLID,SSSL,SCDDMXID ,SCDDMXID,GYSID,CKID,RKLB,ID,JHDJ,JHDJ*SL,sysdate,sysdate,CZRID,CZRID,1 from SM_CG_CGZB_TB where id={pk}"); }*/ try { string msg = SlnDataAccess.ExecuteSQL(sql); // string msg = SlnDataAccess.ExecuteProcedure("SM5604btnCGRK_SP('" + pks + "')"); if (msg == "") { _page.ShowMessage("采购入库成功"); SlnDataAccess.ExecuteProcedure("SM5604btnCGRKFX_SP('" + string.Join(",",lstDJBH) + "','" + pks + "')"); //RDIFramework.Utilities.LogHelper.WriteException(new Exception("SM5604|" // + "SM5604btnCGRKFX_SP('" + string.Join(",", lstDJBH) + "','" + // pks + "')")); _page.btnQuery_Click(null,null); return; } else { _page.ShowMessage("采购入库成功"); return; } } catch (Exception ex) { this._page.ShowMessage(ex.Message); } } #endregion #region SFSCTP 是否上传图片 private int SFSCTP(string CGZBID) { string sql = "SELECT WLID, ZT,JE,RKLB,(SELECT XTWLLBID FROM SM_ZDB_XTWL_TB T WHERE T.ID=ZB.WLID) as XTWLLBID," + " (SELECT COUNT(FJ.ID) From SM_CG_ZJFJ_TB FJ Where FJ.CGZBID=ZB.ID) as TPJLSL " + " FROM SM_CG_CGZB_TB ZB Where ZB.ID='" + CGZBID + "'"; DataTable dt = SlnDataAccess.GetDataTable(sql); int is_success = 0; if (dt.Rows.Count > 0) { if (ConvertFunction.ObjToInt32(dt.Rows[0]["RKLB"]) != 9 && ConvertFunction.ObjToInt32(dt.Rows[0]["ZT"]) != 2 && ConvertFunction.ObjToDouble(dt.Rows[0]["JE"]) > 1000 && ConvertFunction.ObjToInt32(dt.Rows[0]["XTWLLBID"]) != 10 && ConvertFunction.ObjToInt32(dt.Rows[0]["WLID"]) != 79071 && ConvertFunction.ObjToInt32(dt.Rows[0]["TPJLSL"]) < 2) {/*wlid=79071 外购成品 不需要上传图片*/ is_success = 1;/*等于1 需要上传图片*/ } } return is_success; } #endregion #region ReturnJson private string ReturnJson(string DJBHList, string CGZBIDList) { SortedList mySL = new SortedList { {"DJBHList",DJBHList},{ "CGZBIDList",CGZBIDList} }; return SortedListToWxJson(mySL); ; } #endregion #region SortedList表转JSON方法 public string SortedListToWxJson(SortedList mySL) { try { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("{"); foreach (DictionaryEntry e in mySL) { object value = e.Value; sb.Append("\""); sb.Append(e.Key); sb.Append("\":\""); if (!String.IsNullOrEmpty(value.ToString()) && value != DBNull.Value) { sb.Append(value).Replace("\\", "/"); } else { sb.Append(""); } sb.Append("\","); } sb = sb.Remove(sb.Length - 1, 1); sb.Append("}"); return sb.ToString(); } catch (Exception) { return ""; } } #endregion void AddUniqueDJBH(List<string> lstDJBH, string DJBH) { if (!lstDJBH.Contains(DJBH)) { lstDJBH.Add(DJBH); } } } }