protected override void billSave() { #region 数据有效性验证 if (docFLAG.SelectedValue != "N") { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString())) { goodsData.Add(newDict[i]); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM dat_ck_doc where seqno = '" + docBILLNO.Text + "'") && docBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); //处理单号前缀 docSEQNO.Text = "DSC" + docSEQNO.Text.Substring(3, docSEQNO.Text.Length - 3); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } MyTable mtType = new MyTable("DAT_CK_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", "DSC"); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("XSTYPE", "1"); decimal subNum = 0;//总金额 List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_CK_COM"); //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("delete dat_ck_com where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); //判断含税进价,为0时不能保存 string isJiFei = string.Format("select 1 from DOC_GOODS t where iscf = 'N' and gdseq = '{0}'", mtTypeMx.ColRow["GDSEQ"].ToString()); if (DbHelperOra.Exists(isJiFei)) { if (PubFunc.StrIsEmpty(mtTypeMx.ColRow["HSJJ"].ToString()) || mtTypeMx.ColRow["HSJJ"].ToString() == "0") { Alert.Show("商品【含税进价】为0或空,无法进行【定数出库管理】操作。"); return; } } mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow.Add("ROWNO", i + 1); mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow.Add("XSSL", 0); mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); subNum = subNum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBSUM", subNum); cmdList.AddRange(mtType.InsertCommand()); DbHelperOra.ExecuteSqlTran(cmdList); Alert.Show("定数出库信息保存成功!"); //billNew(); billOpen(docBILLNO.Text); billLockDoc(true); }
protected void btnOk() { if (Doc.DbGetSysPara("LOCKSTOCK") == "Y") { Alert.Show("系统库存已被锁定,请等待物资管理科结存处理完毕再做审核处理!", "消息提醒", MessageBoxIcon.Warning); return; } #region 数据有效性验证 decimal subsum = 0;//总金额 if (docFLAG.SelectedValue != "S") { Alert.Show("非『已审批』单据不能申领确定!", "提示信息", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } //验证科室是否盘点 if (DbHelperOra.Exists("SELECT 1 FROM DAT_PD_LOCK WHERE DEPTID IN('" + docDEPTOUT.SelectedValue + "','" + docDEPTID.SelectedValue + "') AND FLAG='N'")) { Alert.Show("出库或申领科室正在盘点,请检查!"); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) { goodsData.Add(newDict[i]); subsum = subsum + decimal.Parse(newDict[i]["HSJE"].ToString()); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM DAT_CK_DOC WHERE SEQNO = '" + docBILLNO.Text + "'") && docBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } else { string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'N') FROM DAT_CK_DOC WHERE SEQNO='{0}'", docBILLNO.Text)); if (!PubFunc.StrIsEmpty(flg) && (",N,R,S").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { docSEQNO.Text = docBILLNO.Text; docBILLNO.Enabled = false; } } MyTable mtType = new MyTable("DAT_CK_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("SUBSUM", subsum); mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_CK_COM"); //MyTable mtTypeExt = new MyTable("DAT_CK_EXT"); //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("delete dat_ck_com where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 cmdList.AddRange(mtType.InsertCommand()); for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow["XSSL"] = decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); mtTypeMx.ColRow["HSJE"] = decimal.Parse(mtTypeMx.ColRow["HSJJ"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); if (decimal.Parse(mtTypeMx.ColRow["XSSL"].ToString()) < 0 || (decimal.Parse(mtTypeMx.ColRow["XSSL"].ToString()) > decimal.Parse(mtTypeMx.ColRow["DHSL"].ToString()) && (mtTypeMx.ColRow["NUM1NAME"].ToString() == "非赠品"))) { Alert.Show("单据号中存在拣货数量小于0或拣货数量大于申领数量!", "消息提示", MessageBoxIcon.Warning); return; } mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); cmdList.Add(mtTypeMx.Insert()); } OracleParameter[] parameters = { new OracleParameter("VTASKID", OracleDbType.Varchar2, 20), new OracleParameter("VPARA", OracleDbType.Varchar2, 800) }; parameters[0].Value = BillType; parameters[1].Value = "'" + docBILLNO.Text + "','" + BillType + "','" + UserAction.UserID + "','AUDIT'"; cmdList.Add(new CommandInfo("P_EXECTASK", parameters, CommandType.StoredProcedure)); bool flag = false; try { flag = DbHelperOra.ExecuteSqlTran(cmdList); } catch (Exception ex) { Alert.Show(errorParse(ex.Message), "消息提示", MessageBoxIcon.Warning); return; } if (flag) { billLockDoc(true); //增加待办事宜 DbHelperOra.ExecuteSql("UPDATE DAT_DO_LIST SET FLAG = 'Y' WHERE PARA='" + docBILLNO.Text.Trim() + "'"); if (DbHelperOra.Exists("select 1 from dat_ck_com where seqno = '" + docBILLNO.Text.Trim() + "' and gdseq in (select gdseq from doc_goods where catid0 = 1 )") == true) { Alert.Show("商品出库确认完成!需要打印试剂条码!", "消息提示", MessageBoxIcon.Information); } else { Alert.Show("商品出库确认完成!", "消息提示", MessageBoxIcon.Information); OperLog("科室申领", "出库确认单据【" + docBILLNO.Text + "】"); } billOpen(docBILLNO.Text); } else { Alert.Show("商品出库确认出错!!!", "错误提示", MessageBoxIcon.Error); } }
private void save(string flag = "N") { #region 数据有效性验证 if (docFLAG.SelectedValue != "N") { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString())) { if (newDict[i]["BZSL"].ToString() == "0" || string.IsNullOrWhiteSpace(newDict[i]["BZSL"].ToString())) { Alert.Show("第【" + (i + 1) + "】行【调拨数量】为空,请填写!"); return; } object DSBZSL = DbHelperOra.GetSingle(string.Format(@"SELECT DSHL FROM DAT_GOODSDS_LOG WHERE GDSEQ = '{0}' AND DEPTIN = '{1}' AND BARCODE = '{2}'", newDict[i]["GDSEQ"].ToString(), docDEPTOUT.SelectedValue, newDict[i]["DSCODE"].ToString())); object FDSKC = DbHelperOra.GetSingle(string.Format(@"SELECT (A.KCSL - NVL(B.DSSL, 0)) KSSPSL FROM (SELECT GDSEQ, SUM(KCSL) KCSL FROM DAT_GOODSSTOCK A WHERE KCSL > 0 AND A.DEPTID = '{1}' AND A.GDSEQ = '{0}' GROUP BY GDSEQ) A, (SELECT GDSEQ, SUM(DSHL) DSSL FROM DAT_GOODSDS_LOG WHERE DEPTIN = '{1}' AND FLAG = 'N' AND SL > 0 AND DSHL > 0 AND GDSEQ = '{0}' GROUP BY GDSEQ) B WHERE A.GDSEQ = B.GDSEQ(+)", newDict[i]["GDSEQ"].ToString(), docDEPTOUT.SelectedValue)); if (string.IsNullOrWhiteSpace(newDict[i]["PH"].ToString())) { Alert.Show("第【" + (i + 1) + "】行【批号】为空,请填写!"); return; } //if (newDict[i]["ISDS"].ToString() == "定数") if (!string.IsNullOrWhiteSpace(newDict[i]["DSCODE"].ToString())) { //if (newDict[i]["BZSL"].ToString() != newDict[i]["DSBZSL"].ToString()) if (newDict[i]["BZSL"].ToString() != DSBZSL.ToString()) { //newDict[i]["BZSL"] = newDict[i]["DSBZSL"].ToString(); Alert.Show("第【" + (i + 1) + "】行为定数,【调拨数量】不允许由【" + DSBZSL.ToString() + "】调整为【" + newDict[i]["BZSL"].ToString() + "】,请修改!"); return; } } else { if (Convert.ToDecimal(newDict[i]["BZSL"].ToString()) > Convert.ToDecimal(FDSKC.ToString())) { //newDict[i]["BZSL"] = newDict[i]["DSBZSL"].ToString(); Alert.Show("第【" + (i + 1) + "】行为非定数,不允许大于非定数库存数量【" + FDSKC.ToString() + "】,请修改!"); return; } } goodsData.Add(newDict[i]); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM dat_kd_doc where seqno = '" + docBILLNO.Text + "'") && docBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); //重新拼单号 docSEQNO.Text = "KSD" + docSEQNO.Text.Substring(3, docSEQNO.Text.Length - 3); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } MyTable mtType = new MyTable("DAT_KD_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", "KSD"); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_KD_COM"); decimal subNum = 0; //总金额 //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("DELETE DAT_KD_COM WHERE SEQNO='" + docBILLNO.Text + "'", null)); //删除单据明细 for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow.Add("XSSL", Convert.ToInt32(mtTypeMx.ColRow["BZHL"]) * Convert.ToInt32(mtTypeMx.ColRow["BZSL"])); mtTypeMx.ColRow["HSJE"] = Convert.ToDecimal(mtTypeMx.ColRow["XSSL"]) * Convert.ToDecimal(mtTypeMx.ColRow["HSJJ"]); mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); subNum = subNum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBSUM", subNum); cmdList.AddRange(mtType.InsertCommand()); DbHelperOra.ExecuteSqlTran(cmdList); if (flag == "N") { Alert.Show("科室商品调拨信息保存成功!"); } //billNew(); OperLog("科室调拨", "修改单据【" + docBILLNO.Text.Trim() + "】"); billOpen(docBILLNO.Text); btnDel.Enabled = true; billLockDoc(true); SaveSuccess = true; }
private void save(string flag = "N") { #region 数据有效性验证 if (docFLAG.SelectedValue != "N") { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString())) { if (newDict[i].ContainsKey("STR2") && goodsData.Count > 0 && goodsData.Where(x => x["STR2"].ToString() == newDict[i]["STR2"].ToString()).Count() > 0) { Alert.Show("条码[" + newDict[i]["STR2"] + "]扫描重复!", "消息提示", MessageBoxIcon.Warning); return; } goodsData.Add(newDict[i]); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } MyTable mtType = new MyTable("DAT_CK_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", "DST"); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("XSTYPE", "2"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_CK_COM"); //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("delete dat_ck_com where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 Decimal subsum = 0; for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); //mtTypeMx.ColRow.Add("XSSL", mtTypeMx.ColRow["BZHL"]); mtTypeMx.ColRow.Add("XSSL", -Math.Abs(decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()))); mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); mtTypeMx.ColRow["HSJE"] = -Math.Abs(decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["HSJJ"].ToString())); subsum = subsum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBSUM", subsum); cmdList.AddRange(mtType.InsertCommand()); DbHelperOra.ExecuteSqlTran(cmdList); if (flag == "N") { Alert.Show("定数商品退货信息保存成功!"); } OperLog("定数退货", "修改单据【" + docBILLNO.Text + "】"); billOpen(docBILLNO.Text); btnDel.Enabled = true; billLockDoc(true); SaveSuccess = true; }
private void save(string flag = "N") { #region 数据有效性验证 if (docFLAG.SelectedValue != "N") { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString())) { goodsData.Add(newDict[i]); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM dat_xs_doc where seqno = '" + docBILLNO.Text + "'") && docBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); //重新拼单号 docSEQNO.Text = "DSH" + docSEQNO.Text.Substring(3, docSEQNO.Text.Length - 3); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } MyTable mtType = new MyTable("DAT_XS_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", "DSH"); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_XS_COM"); decimal subNum = 0; //总金额 //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("DELETE DAT_XS_COM WHERE SEQNO='" + docBILLNO.Text + "'", null)); //删除单据明细 for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow.Add("XSSL", mtTypeMx.ColRow["BZHL"]); mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); subNum = subNum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBSUM", subNum); cmdList.AddRange(mtType.InsertCommand()); DbHelperOra.ExecuteSqlTran(cmdList); if (flag == "N") { Alert.Show("条码回收信息保存成功!"); } OperLog("条码回收", "修改单据【" + docBILLNO.Text + "】"); //billNew(); billOpen(docBILLNO.Text); btnDel.Enabled = true; billLockDoc(true); SaveSuccess = true; }
private void save(string flag = "N") { #region 检查有效性 if (("NR").IndexOf(ddlFLAG.SelectedValue) < 0) { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } if (Convert.ToDateTime(dpkPDRQ.Text) < Convert.ToDateTime(DateTime.Now.ToShortDateString())) { Alert.Show("盘点日期不能小于当前日期"); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["CODE"]).ToList(); List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 if (newDict.Count > 0) { for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["CODE"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["NAME"].ToString())) { goodsData.Add(newDict[i]); } } } else { Alert.Show("请追加盘点部门!", "消息提示", MessageBoxIcon.Warning); return; } #endregion if (PubFunc.StrIsEmpty(tbxBILLNO.Text)) { tbxBILLNO.Text = BillSeqGet(); } MyTable mtType = new MyTable("dat_pdplan_doc"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = tbxBILLNO.Text; mtType.ColRow["FLAG"] = "N";//所有单据在保存时单据状态一律为新增N mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); //mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("dat_pdplan_com"); //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("delete dat_pdplan_com where seqno='" + tbxBILLNO.Text + "'", null)); //删除单据明细 cmdList.AddRange(mtType.InsertCommand()); for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", tbxBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Remove("KSWC"); mtTypeMx.ColRow.Remove("FLAGNAME"); cmdList.Add(mtTypeMx.Insert()); } DbHelperOra.ExecuteSqlTran(cmdList); tbxBILLNO.Enabled = false; if (flag == "N") { Alert.Show("单据保存成功"); } billOpen(tbxBILLNO.Text); OperLog("盘点计划", "修改单据【" + tbxBILLNO.Text + "】"); SaveSuccess = true; }
protected override void billSave() { #region 数据有效性验证 if (ddlFLAG.SelectedValue != "N") { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } if (ddlKCTYPE.SelectedValue.Length < 1) { Alert.Show("请选择【损益类别】"); return; } if (PubFunc.FormDataCheck(FormDoc).Length > 0) { return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行、批号填写是否符合要求 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) { goodsData.Add(newDict[i]); } if (string.IsNullOrWhiteSpace(newDict[i]["BZHL"].ToString()) || string.IsNullOrWhiteSpace(newDict[i]["UNIT"].ToString())) { Alert.Show("商品包装单位信息错误,请联系管理员进行维护!", "消息提示", MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(newDict[i]["SYSL"].ToString())) { Alert.Show("请填写正确的损益数量", "消息提示", MessageBoxIcon.Warning); return; } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } #endregion if (PubFunc.StrIsEmpty(tbxBILLNO.Text)) { tbxBILLNO.Text = BillSeqGet(); tbxBILLNO.Enabled = false; } MyTable mtType = new MyTable("DAT_SY_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = tbxBILLNO.Text; mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); //如果是代管商品,把发送标志设为G-即不发送 if (isDg()) { mtType.ColRow.Add("ISSEND", "G"); } List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_SY_COM"); decimal subNum = 0; //总金额 //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("delete DAT_SY_COM where seqno='" + tbxBILLNO.Text + "'", null)); //删除单据明细 for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); //判断含税进价,为0时不能保存 string isJiFei = string.Format("select 1 from DOC_GOODS t where iscf = 'N' and gdseq = '{0}'", mtTypeMx.ColRow["GDSEQ"].ToString()); if (DbHelperOra.Exists(isJiFei)) { if (PubFunc.StrIsEmpty(mtTypeMx.ColRow["HSJJ"].ToString()) || mtTypeMx.ColRow["HSJJ"].ToString() == "0") { Alert.Show("商品【含税进价】为0或空,无法进行【商品损益管理】操作。"); return; } } //重新计算金额 mtTypeMx.ColRow["HSJE"] = Convert.ToDecimal(mtTypeMx.ColRow["SYSL"]) * Convert.ToDecimal(mtTypeMx.ColRow["HSJJ"]); mtTypeMx.ColRow["BHSJE"] = Convert.ToDecimal(mtTypeMx.ColRow["SYSL"]) * Convert.ToDecimal(mtTypeMx.ColRow["BHSJJ"]); mtTypeMx.ColRow["LSJE"] = Convert.ToDecimal(mtTypeMx.ColRow["SYSL"]) * Convert.ToDecimal(mtTypeMx.ColRow["LSJ"]); subNum = subNum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); mtTypeMx.ColRow.Add("SEQNO", tbxBILLNO.Text); mtTypeMx.ColRow["BZSL"] = mtTypeMx.ColRow["SYSL"]; mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow.Remove("UNITNAME"); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow["SUBSUM"] = subNum; //mtType.ColRow.Add("SUBSUM", subNum); cmdList.AddRange(mtType.InsertCommand()); DbHelperOra.ExecuteSqlTran(cmdList); Alert.Show("损益单信息保存成功!"); //billNew(); OperLog("商品损益", "修改单据【" + tbxBILLNO.Text + "】"); billOpen(tbxBILLNO.Text); billLockDoc(true); }