Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public string Update(BarCode.Model.InvPosition model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update @u8.InvPosition set ");
            if (model.dVDate != null)
            {
                strSql.Append("dVDate='" + model.dVDate + "',");
            }
            else
            {
                strSql.Append("dVDate= null ,");
            }
            if (model.iNum != null)
            {
                strSql.Append("iNum=" + model.iNum + ",");
            }
            else
            {
                strSql.Append("iNum= null ,");
            }
            if (model.cMemo != null)
            {
                strSql.Append("cMemo='" + model.cMemo + "',");
            }
            else
            {
                strSql.Append("cMemo= null ,");
            }
            if (model.cHandler != null)
            {
                strSql.Append("cHandler='" + model.cHandler + "',");
            }
            else
            {
                strSql.Append("cHandler= null ,");
            }
            if (model.dDate != null)
            {
                strSql.Append("dDate='" + model.dDate + "',");
            }
            else
            {
                strSql.Append("dDate= null ,");
            }
            if (model.bRdFlag != null)
            {
                strSql.Append("bRdFlag=" + model.bRdFlag + ",");
            }
            if (model.cAssUnit != null)
            {
                strSql.Append("cAssUnit='" + model.cAssUnit + "',");
            }
            else
            {
                strSql.Append("cAssUnit= null ,");
            }
            if (model.cBVencode != null)
            {
                strSql.Append("cBVencode='" + model.cBVencode + "',");
            }
            else
            {
                strSql.Append("cBVencode= null ,");
            }
            if (model.iTrackId != null)
            {
                strSql.Append("iTrackId=" + model.iTrackId + ",");
            }
            else
            {
                strSql.Append("iTrackId= null ,");
            }
            if (model.dMadeDate != null)
            {
                strSql.Append("dMadeDate='" + model.dMadeDate + "',");
            }
            else
            {
                strSql.Append("dMadeDate= null ,");
            }
            if (model.iMassDate != null)
            {
                strSql.Append("iMassDate=" + model.iMassDate + ",");
            }
            else
            {
                strSql.Append("iMassDate= null ,");
            }
            if (model.cMassUnit != null)
            {
                strSql.Append("cMassUnit=" + model.cMassUnit + ",");
            }
            else
            {
                strSql.Append("cMassUnit= null ,");
            }
            if (model.cvmivencode != null)
            {
                strSql.Append("cvmivencode='" + model.cvmivencode + "',");
            }
            else
            {
                strSql.Append("cvmivencode= null ,");
            }
            if (model.iExpiratDateCalcu != null)
            {
                strSql.Append("iExpiratDateCalcu=" + model.iExpiratDateCalcu + ",");
            }
            else
            {
                strSql.Append("iExpiratDateCalcu= null ,");
            }
            if (model.cExpirationdate != null)
            {
                strSql.Append("cExpirationdate='" + model.cExpirationdate + "',");
            }
            else
            {
                strSql.Append("cExpirationdate= null ,");
            }
            if (model.dExpirationdate != null)
            {
                strSql.Append("dExpirationdate='" + model.dExpirationdate + "',");
            }
            else
            {
                strSql.Append("dExpirationdate= null ,");
            }
            if (model.cInVouchType != null)
            {
                strSql.Append("cInVouchType='" + model.cInVouchType + "',");
            }
            else
            {
                strSql.Append("cInVouchType= null ,");
            }
            if (model.cVerifier != null)
            {
                strSql.Append("cVerifier='" + model.cVerifier + "',");
            }
            else
            {
                strSql.Append("cVerifier= null ,");
            }
            if (model.dVeriDate != null)
            {
                strSql.Append("dVeriDate='" + model.dVeriDate + "',");
            }
            else
            {
                strSql.Append("dVeriDate= null ,");
            }
            if (model.dVouchDate != null)
            {
                strSql.Append("dVouchDate='" + model.dVouchDate + "',");
            }
            else
            {
                strSql.Append("dVouchDate= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where AutoID=" + model.AutoID + "");
            return(strSql.ToString());
        }
Beispiel #2
0
        private void btn保存_Click(object sender, EventArgs e)
        {
            try
            {
                int i1 = dtTable.Rows.Count;
                int i2 = MobileBaseDLL.ClsBaseDataInfo.ReturnInt(txt条数.Text.Trim());
                if (i1 != i2)
                {
                    throw new Exception("条形码数量不一致");
                }
                if (dtTable == null || dtTable.Rows.Count < 1)
                {
                    throw new Exception("请先扫条形码");
                }

                decimal d本次入库累计 = 0;
                for (int i = 0; i < dtTable.Rows.Count; i++)
                {
                    dtTable.Rows[i]["bUsed"]  = -1;
                    dtTable.Rows[i]["bUsed2"] = 0;

                    d本次入库累计 = d本次入库累计 + MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库数量"]);
                }

                DialogResult d = MessageBox.Show("本次入库数量:" + d本次入库累计.ToString(), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                if (d != DialogResult.Yes)
                {
                    return;
                }

                string sErr = "";
                for (int i = 0; i < dtTable.Rows.Count; i++)
                {
                    long lbUsed = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["bUsed"]);
                    if (lbUsed != 0)
                    {
                        continue;
                    }

                    long   lAutoID = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["入库单子表ID"]);
                    string s物料编码   = dtTable.Rows[i]["物料编码"].ToString().Trim();

                    string s货位编码 = dtTable.Rows[i]["货位编码"].ToString().Trim();

                    decimal d货位现存数量 = 0;
                    decimal d货位现存件数 = 0;
                    clsu8.Get货位现存量(s物料编码, s货位编码, out d货位现存数量, out d货位现存件数);

                    decimal d货位本次发料数量 = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["本次入库数量"]);
                    decimal d货位本次发料件数 = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["本次入库件数"]);

                    decimal d本次货位累计入库数量 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库数量"]);
                    decimal d本次货位累计入库件数 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库件数"]);

                    string s超出  = "行" + (i + 1);
                    string s超出2 = "行" + (i + 1);

                    for (int j = i + 1; j < dtTable.Rows.Count; j++)
                    {
                        long lAutoID2 = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[j]["入库单子表ID"]);
                        if (lAutoID == lAutoID2)
                        {
                            string s货位编码2 = dtTable.Rows[j]["货位编码"].ToString().Trim();
                            if (s货位编码 == s货位编码2)
                            {
                                d本次货位累计入库数量 += MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[j]["本次入库数量"]);
                                d本次货位累计入库件数 += MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[j]["本次入库件数"]);

                                dtTable.Rows[j]["bUsed"] = lAutoID;
                                s超出 = s超出 + "," + "行" + (j + 1);
                            }
                        }
                    }

                    dtTable.Rows[i]["bUsed"] = lAutoID;
                }

                for (int i = 0; i < dtTable.Rows.Count; i++)
                {
                    long lbUsed = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["bUsed2"]);
                    if (lbUsed != 0)
                    {
                        continue;
                    }

                    long   lAutoID = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["入库单子表ID"]);
                    string s物料编码   = dtTable.Rows[i]["物料编码"].ToString().Trim();

                    string s货位编码 = dtTable.Rows[i]["货位编码"].ToString().Trim();

                    decimal d货位现存数量 = 0;
                    decimal d货位现存件数 = 0;
                    clsu8.Get货位现存量(s物料编码, s货位编码, out d货位现存数量, out d货位现存件数);

                    decimal d货位本次发料数量 = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["本次入库数量"]);
                    decimal d货位本次发料件数 = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["本次入库件数"]);

                    decimal d本次累计入库数量 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库数量"]);
                    decimal d本次累计入库件数 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库件数"]);

                    decimal d单据数量 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["数量"]);
                    decimal d单据件数 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["件数"]);

                    string s超出  = "行" + (i + 1);
                    string s超出2 = "行" + (i + 1);

                    for (int j = i + 1; j < dtTable.Rows.Count; j++)
                    {
                        long lAutoID2 = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[j]["入库单子表ID"]);
                        if (lAutoID == lAutoID2)
                        {
                            d本次累计入库数量 += MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[j]["本次入库数量"]);
                            d本次累计入库件数 += MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[j]["本次入库件数"]);

                            dtTable.Rows[j]["bUsed2"] = lAutoID;
                            s超出2 = s超出2 + "," + "行" + (j + 1);
                        }
                    }

                    if (d本次累计入库数量 > d单据数量 || d本次累计入库件数 > d单据件数)
                    {
                        sErr = sErr + s超出2 + "超出单据量\r\n";
                    }
                    if (d本次累计入库数量 < d单据数量 || d本次累计入库件数 < d单据件数)
                    {
                        sErr = sErr + s超出2 + "入库不足单据量\r\n";
                    }

                    dtTable.Rows[i]["bUsed2"] = lAutoID;
                }


                if (sErr.Length > 0)
                {
                    throw new Exception(sErr);
                }

                ArrayList aList = new ArrayList();
                for (int i = 0; i < dtTable.Rows.Count; i++)
                {
                    long iID       = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["入库单ID"]);
                    long iIDDetail = MobileBaseDLL.ClsBaseDataInfo.ReturnLong(dtTable.Rows[i]["入库单子表ID"]);

                    decimal d货位数量 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库数量"]);
                    decimal d货位件数 = MobileBaseDLL.ClsBaseDataInfo.ReturnDecimal(dtTable.Rows[i]["本次入库件数"]);
                    string  s货位件数 = "null";
                    if (d货位件数 > 0)
                    {
                        s货位件数 = d货位件数.ToString();
                    }

                    string s辅计量编码 = "null";
                    if (dtTable.Rows[i]["辅计量编码"].ToString().Trim() != "")
                    {
                        s辅计量编码 = dtTable.Rows[i]["辅计量编码"].ToString().Trim();
                    }

                    Model.InvPosition model = new BarCode.Model.InvPosition();
                    model.RdsID             = iIDDetail;
                    model.RdID              = iID;
                    model.cWhCode           = dtTable.Rows[i]["仓库编码"].ToString().Trim();
                    model.cPosCode          = dtTable.Rows[i]["货位编码"].ToString().Trim();
                    model.cInvCode          = dtTable.Rows[i]["物料编码"].ToString().Trim();
                    model.iQuantity         = d货位数量;
                    model.iNum              = d货位件数;
                    model.cHandler          = MobileBaseDLL.ClsBaseDataInfo.sUserName;
                    model.dDate             = MobileBaseDLL.ClsBaseDataInfo.ReturnDate(date单据日期.Value.ToString("yyyy-MM-dd"));
                    model.bRdFlag           = 1;
                    model.cAssUnit          = s辅计量编码;
                    model.iTrackId          = 0;
                    model.iExpiratDateCalcu = 0;
                    model.cvouchtype        = "10";
                    model.dVouchDate        = MobileBaseDLL.ClsBaseDataInfo.ReturnDate(date单据日期.Value.ToString("yyyy-MM-dd"));

                    DAL.InvPosition dal  = new BarCode.DAL.InvPosition();
                    string          sSQL = dal.Add(model);
                    aList.Add(sSQL);

                    sSQL = @"
if exists (select * from @u8.InvPositionSum where  cInvCode = 'aaaaaaaaaa' and cWhCode = 'cccccccccc' and cPosCode = 'bbbbbbbbbb')
    update @u8.InvPositionSum set iQuantity = isnull(iQuantity,0) + dddddddddd,iNum = isnull(iNum,0) + eeeeeeeeee where cInvCode = 'aaaaaaaaaa' and cWhCode = 'cccccccccc' and cPosCode = 'bbbbbbbbbb'
else
    insert into @u8.InvPositionSum(cInvCode,cWhCode,cPosCode,iQuantity,iNum)
    values('aaaaaaaaaa','cccccccccc','bbbbbbbbbb',dddddddddd,eeeeeeeeee)
";
                    sSQL = sSQL.Replace("aaaaaaaaaa", model.cInvCode);
                    sSQL = sSQL.Replace("bbbbbbbbbb", model.cPosCode);
                    sSQL = sSQL.Replace("cccccccccc", model.cWhCode);
                    sSQL = sSQL.Replace("dddddddddd", model.iQuantity.ToString());

                    if (model.iNum == 0)
                    {
                        sSQL = sSQL.Replace("eeeeeeeeee", "Null");
                    }
                    else
                    {
                        sSQL = sSQL.Replace("eeeeeeeeee", model.iNum.ToString());
                    }
                    aList.Add(sSQL);
                }

                if (aList.Count > 0)
                {
                    clsSQLCommond.ExecSqlTran(aList);

                    dtTable.Clear();
                    txt货位.Text  = "";
                    txt条数.Text  = "";
                    txt条形码.Text = "";
                    txt条数.Focus();
                    msgBox.textBox1.Text = "保存入库单货位信息成功";
                    msgBox.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                msgBox.textBox1.Text = "保存失败:\r\n" + ee.Message;
                msgBox.ShowDialog();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(BarCode.Model.InvPosition model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.RdsID != null)
            {
                strSql1.Append("RdsID,");
                strSql2.Append("" + model.RdsID + ",");
            }
            if (model.RdID != null)
            {
                strSql1.Append("RdID,");
                strSql2.Append("" + model.RdID + ",");
            }
            if (model.cWhCode != null)
            {
                strSql1.Append("cWhCode,");
                strSql2.Append("'" + model.cWhCode + "',");
            }
            if (model.cPosCode != null)
            {
                strSql1.Append("cPosCode,");
                strSql2.Append("'" + model.cPosCode + "',");
            }
            if (model.cInvCode != null)
            {
                strSql1.Append("cInvCode,");
                strSql2.Append("'" + model.cInvCode + "',");
            }
            if (model.cBatch != null)
            {
                strSql1.Append("cBatch,");
                strSql2.Append("'" + model.cBatch + "',");
            }
            if (model.cFree1 != null)
            {
                strSql1.Append("cFree1,");
                strSql2.Append("'" + model.cFree1 + "',");
            }
            if (model.cFree2 != null)
            {
                strSql1.Append("cFree2,");
                strSql2.Append("'" + model.cFree2 + "',");
            }
            if (model.dVDate != null)
            {
                strSql1.Append("dVDate,");
                strSql2.Append("'" + model.dVDate + "',");
            }
            if (model.iQuantity != null)
            {
                strSql1.Append("iQuantity,");
                strSql2.Append("" + model.iQuantity + ",");
            }
            if (model.iNum != null)
            {
                strSql1.Append("iNum,");
                strSql2.Append("" + model.iNum + ",");
            }
            if (model.cMemo != null)
            {
                strSql1.Append("cMemo,");
                strSql2.Append("'" + model.cMemo + "',");
            }
            if (model.cHandler != null)
            {
                strSql1.Append("cHandler,");
                strSql2.Append("'" + model.cHandler + "',");
            }
            if (model.dDate != null)
            {
                strSql1.Append("dDate,");
                strSql2.Append("'" + model.dDate + "',");
            }
            if (model.bRdFlag != null)
            {
                strSql1.Append("bRdFlag,");
                strSql2.Append("" + model.bRdFlag + ",");
            }
            if (model.cSource != null)
            {
                strSql1.Append("cSource,");
                strSql2.Append("'" + model.cSource + "',");
            }
            if (model.cFree3 != null)
            {
                strSql1.Append("cFree3,");
                strSql2.Append("'" + model.cFree3 + "',");
            }
            if (model.cFree4 != null)
            {
                strSql1.Append("cFree4,");
                strSql2.Append("'" + model.cFree4 + "',");
            }
            if (model.cFree5 != null)
            {
                strSql1.Append("cFree5,");
                strSql2.Append("'" + model.cFree5 + "',");
            }
            if (model.cFree6 != null)
            {
                strSql1.Append("cFree6,");
                strSql2.Append("'" + model.cFree6 + "',");
            }
            if (model.cFree7 != null)
            {
                strSql1.Append("cFree7,");
                strSql2.Append("'" + model.cFree7 + "',");
            }
            if (model.cFree8 != null)
            {
                strSql1.Append("cFree8,");
                strSql2.Append("'" + model.cFree8 + "',");
            }
            if (model.cFree9 != null)
            {
                strSql1.Append("cFree9,");
                strSql2.Append("'" + model.cFree9 + "',");
            }
            if (model.cFree10 != null)
            {
                strSql1.Append("cFree10,");
                strSql2.Append("'" + model.cFree10 + "',");
            }
            if (model.cAssUnit != null)
            {
                strSql1.Append("cAssUnit,");
                strSql2.Append("'" + model.cAssUnit + "',");
            }
            if (model.cBVencode != null)
            {
                strSql1.Append("cBVencode,");
                strSql2.Append("'" + model.cBVencode + "',");
            }
            if (model.iTrackId != null)
            {
                strSql1.Append("iTrackId,");
                strSql2.Append("" + model.iTrackId + ",");
            }
            if (model.dMadeDate != null)
            {
                strSql1.Append("dMadeDate,");
                strSql2.Append("'" + model.dMadeDate + "',");
            }
            if (model.iMassDate != null)
            {
                strSql1.Append("iMassDate,");
                strSql2.Append("" + model.iMassDate + ",");
            }
            if (model.cMassUnit != null)
            {
                strSql1.Append("cMassUnit,");
                strSql2.Append("" + model.cMassUnit + ",");
            }
            if (model.cvmivencode != null)
            {
                strSql1.Append("cvmivencode,");
                strSql2.Append("'" + model.cvmivencode + "',");
            }
            if (model.iExpiratDateCalcu != null)
            {
                strSql1.Append("iExpiratDateCalcu,");
                strSql2.Append("" + model.iExpiratDateCalcu + ",");
            }
            if (model.cExpirationdate != null)
            {
                strSql1.Append("cExpirationdate,");
                strSql2.Append("'" + model.cExpirationdate + "',");
            }
            if (model.dExpirationdate != null)
            {
                strSql1.Append("dExpirationdate,");
                strSql2.Append("'" + model.dExpirationdate + "',");
            }
            if (model.cvouchtype != null)
            {
                strSql1.Append("cvouchtype,");
                strSql2.Append("'" + model.cvouchtype + "',");
            }
            if (model.cInVouchType != null)
            {
                strSql1.Append("cInVouchType,");
                strSql2.Append("'" + model.cInVouchType + "',");
            }
            if (model.cVerifier != null)
            {
                strSql1.Append("cVerifier,");
                strSql2.Append("'" + model.cVerifier + "',");
            }
            if (model.dVeriDate != null)
            {
                strSql1.Append("dVeriDate,");
                strSql2.Append("'" + model.dVeriDate + "',");
            }
            if (model.dVouchDate != null)
            {
                strSql1.Append("dVouchDate,");
                strSql2.Append("'" + model.dVouchDate + "',");
            }
            strSql.Append("insert into @u8.InvPosition(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1, 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1, 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            return(strSql.ToString());
        }