Ejemplo n.º 1
0
        /// <summary>
        /// 保存发货单扫描数量
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public int iSaveDispatchListChkQty(string sCode, DataTable dtBarCode, string sUid)
        {
            int iCou = 0;

            try
            {
                string sDLCode = sCode;

                SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    decimal dQtyScanSum = 0;        //  累计扫描数量
                    for (int i = 0; i < dtBarCode.Rows.Count; i++)
                    {
                        dQtyScanSum = dQtyScanSum + ClsBaseDataInfo.ReturnObjectToDecimal(dtBarCode.Rows[i]["数量"]);
                    }

                    string    sSQL           = "select a.cDLCode as cCode,b.iRowNo, b.cInvCode,b.iQuantity,b.cDefine31 as 已扫描数量,cast(null as decimal(16,6)) as 本次扫描数量,b.autoid,a.bReturnFlag as 红蓝字 from DispatchList a inner join DispatchLists b on a.DLID  = b.DLID where a.cDLCode = '" + sCode + "' order by b.cInvCode";
                    DataTable dtDispatchList = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];


                    bool bRed = false;
                    if (dtDispatchList != null && dtDispatchList.Rows.Count > 0 && BaseFunction.ReturnInt(dtDispatchList.Rows[0]["红蓝字"]) == 1)
                    {
                        bRed = true;
                    }

                    sSQL = "select getdate()";
                    DataTable dtTime          = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    DateTime  dtmNow          = BaseFunction.ReturnDate(dtTime.Rows[0][0]);
                    string    s_BarCodeRDCode = BaseFunction.ReturnDate(dtTime.Rows[0][0]).ToString("yyMMddHHmmss");
                    dtTime = null;

                    _BarCodeRD   DAL_BarCodeRD   = new _BarCodeRD();
                    _BarCodeList DAL_BarCodeList = new _BarCodeList();

                    if (!bRed)
                    {
                        for (int i = 0; i < dtBarCode.Rows.Count; i++)
                        {
                            string  sInvCode    = dtBarCode.Rows[i]["存货编码"].ToString().Trim();
                            decimal dQtyBarCode = BaseFunction.ReturnDecimal(dtBarCode.Rows[i]["数量"]);


                            //条形码中仅存货编码与入库单对应
                            DataRow[] drCode = dtDispatchList.Select("cInvCode = '" + sInvCode + "'");

                            for (int j = 0; j < drCode.Length; j++)
                            {
                                if (dQtyBarCode <= 0)
                                {
                                    break;
                                }

                                decimal diQuantity = BaseFunction.ReturnDecimal(drCode[j]["iQuantity"]);
                                decimal dQtyScaned = BaseFunction.ReturnDecimal(drCode[j]["已扫描数量"]);
                                decimal dQtyNow    = BaseFunction.ReturnDecimal(drCode[j]["本次扫描数量"]);
                                decimal d          = diQuantity - dQtyScaned - dQtyNow;


                                Model._BarCodeRD model_BarCodeRD = new TH.WebService.Model._BarCodeRD();
                                model_BarCodeRD.sCode      = s_BarCodeRDCode;
                                model_BarCodeRD.BarCode    = dtBarCode.Rows[i]["条形码"].ToString().Trim();
                                model_BarCodeRD.sType      = "销售发货单";
                                model_BarCodeRD.ExsID      = BaseFunction.ReturnLong(drCode[j]["autoid"]);
                                model_BarCodeRD.ExCode     = drCode[j]["cCode"].ToString().Trim();
                                model_BarCodeRD.ExRowNo    = ClsBaseDataInfo.ReturnObjectToLong(drCode[j]["iRowNo"]);
                                model_BarCodeRD.cInvCode   = drCode[j]["cInvCode"].ToString().Trim();
                                model_BarCodeRD.CreateUid  = dtBarCode.Rows[i]["制单人"].ToString().Trim();
                                model_BarCodeRD.CreateDate = dtmNow;
                                model_BarCodeRD.XBarCode   = dtBarCode.Rows[i]["箱码"].ToString().Trim();
                                model_BarCodeRD.RDType     = 2;

                                //条形码数量超出单据数量
                                if (dQtyBarCode >= d)
                                {
                                    model_BarCodeRD.Qty = d;
                                    dQtyScanSum         = dQtyScanSum - d;

                                    drCode[j]["本次扫描数量"] = BaseFunction.ReturnDecimal(drCode[j]["本次扫描数量"]) + d;
                                    dQtyBarCode         = dQtyBarCode - d;
                                }
                                else
                                {
                                    model_BarCodeRD.Qty = dQtyBarCode;
                                    dQtyScanSum         = dQtyScanSum - dQtyBarCode;

                                    drCode[j]["本次扫描数量"] = BaseFunction.ReturnDecimal(drCode[j]["本次扫描数量"]) + dQtyBarCode;
                                    dQtyBarCode         = 0;
                                }

                                sSQL = DAL_BarCodeRD.Add(model_BarCodeRD);
                                iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                if (model_BarCodeRD.XBarCode != "")
                                {
                                    sSQL = @"select count(1) as iCou from _BarCodeRD where BarCode = '111111' and sType = '222222' and sCode = '333333'";
                                    sSQL = sSQL.Replace("111111", model_BarCodeRD.XBarCode);
                                    sSQL = sSQL.Replace("222222", model_BarCodeRD.sType);
                                    sSQL = sSQL.Replace("333333", model_BarCodeRD.sCode);
                                    DataTable dtCheckBox = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                                    int       iCouBox    = BaseFunction.ReturnInt(dtCheckBox.Rows[0][0]);
                                    if (iCouBox == 0)
                                    {
                                        model_BarCodeRD.BarCode = dtBarCode.Rows[i]["箱码"].ToString().Trim();
                                        sSQL = DAL_BarCodeRD.Add(model_BarCodeRD);
                                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);


                                        sSQL = "update _BarCodeList set valid = 0 where BarCode = '" + dtBarCode.Rows[i]["箱码"].ToString().Trim() + "'";
                                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                    }
                                }

                                sSQL = "update DispatchLists set cDefine31 = cast(isnull(cDefine31,0) as decimal(16,6)) + " + model_BarCodeRD.Qty.ToString() + " where autoid = " + model_BarCodeRD.ExsID.ToString();
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                sSQL = "update _BarCodeList set Used = 1 where BarCode = '" + model_BarCodeRD.BarCode + "'";
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                //当可用量为0是,标记条形码失效
                                sSQL = DAL_BarCodeList.sBarCodeQty(model_BarCodeRD.BarCode);
                                DataTable dtQty = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                                if (dtQty != null && dtQty.Rows.Count > 0)
                                {
                                    decimal dQtyUsed = BaseFunction.ReturnDecimal(dtQty.Rows[0][0]);
                                    if (dQtyUsed <= 0)
                                    {
                                        sSQL = "update _BarCodeList set valid = 0 where BarCode = '" + model_BarCodeRD.BarCode + "'";
                                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < dtBarCode.Rows.Count; i++)
                        {
                            string  sInvCode    = dtBarCode.Rows[i]["存货编码"].ToString().Trim();
                            decimal dQtyBarCode = BaseFunction.ReturnDecimal(dtBarCode.Rows[i]["数量"]);


                            //条形码中仅存货编码与入库单对应
                            DataRow[] drCode = dtDispatchList.Select("cInvCode = '" + sInvCode + "'");

                            for (int j = 0; j < drCode.Length; j++)
                            {
                                if (dQtyBarCode >= 0)
                                {
                                    break;
                                }

                                decimal diQuantity = BaseFunction.ReturnDecimal(drCode[j]["iQuantity"]);
                                decimal dQtyScaned = BaseFunction.ReturnDecimal(drCode[j]["已扫描数量"]);
                                decimal dQtyNow    = BaseFunction.ReturnDecimal(drCode[j]["本次扫描数量"]);
                                decimal d          = diQuantity - dQtyScaned - dQtyNow;


                                Model._BarCodeRD model_BarCodeRD = new TH.WebService.Model._BarCodeRD();
                                model_BarCodeRD.sCode      = s_BarCodeRDCode;
                                model_BarCodeRD.BarCode    = dtBarCode.Rows[i]["条形码"].ToString().Trim();
                                model_BarCodeRD.sType      = "销售发货单";
                                model_BarCodeRD.ExsID      = BaseFunction.ReturnLong(drCode[j]["autoid"]);
                                model_BarCodeRD.ExCode     = drCode[j]["cCode"].ToString().Trim();
                                model_BarCodeRD.ExRowNo    = ClsBaseDataInfo.ReturnObjectToLong(drCode[j]["iRowNo"]);
                                model_BarCodeRD.cInvCode   = drCode[j]["cInvCode"].ToString().Trim();
                                model_BarCodeRD.CreateUid  = dtBarCode.Rows[i]["制单人"].ToString().Trim();
                                model_BarCodeRD.CreateDate = dtmNow;
                                model_BarCodeRD.XBarCode   = dtBarCode.Rows[i]["箱码"].ToString().Trim();
                                model_BarCodeRD.RDType     = 2;

                                //条形码数量超出单据数量
                                if (dQtyBarCode <= d)
                                {
                                    model_BarCodeRD.Qty = d;
                                    dQtyScanSum         = dQtyScanSum - d;

                                    drCode[j]["本次扫描数量"] = BaseFunction.ReturnDecimal(drCode[j]["本次扫描数量"]) + d;
                                    dQtyBarCode         = dQtyBarCode - d;
                                }
                                else
                                {
                                    model_BarCodeRD.Qty = dQtyBarCode;
                                    dQtyScanSum         = dQtyScanSum - dQtyBarCode;

                                    drCode[j]["本次扫描数量"] = BaseFunction.ReturnDecimal(drCode[j]["本次扫描数量"]) + dQtyBarCode;
                                    dQtyBarCode         = 0;
                                }

                                sSQL = DAL_BarCodeRD.Add(model_BarCodeRD);
                                iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                if (model_BarCodeRD.XBarCode != "")
                                {
                                    sSQL = @"select count(1) as iCou from _BarCodeRD where BarCode = '111111' and sType = '222222' and sCode = '333333'";
                                    sSQL = sSQL.Replace("111111", model_BarCodeRD.XBarCode);
                                    sSQL = sSQL.Replace("222222", model_BarCodeRD.sType);
                                    sSQL = sSQL.Replace("333333", model_BarCodeRD.sCode);
                                    DataTable dtCheckBox = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                                    int       iCouBox    = BaseFunction.ReturnInt(dtCheckBox.Rows[0][0]);
                                    if (iCouBox == 0)
                                    {
                                        model_BarCodeRD.BarCode = dtBarCode.Rows[i]["箱码"].ToString().Trim();
                                        sSQL = DAL_BarCodeRD.Add(model_BarCodeRD);
                                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);


                                        sSQL = "update _BarCodeList set valid = 0 where BarCode = '" + dtBarCode.Rows[i]["箱码"].ToString().Trim() + "'";
                                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                    }
                                }

                                sSQL = "update DispatchLists set cDefine31 = cast(isnull(cDefine31,0) as decimal(16,6)) + " + model_BarCodeRD.Qty.ToString() + " where autoid = " + model_BarCodeRD.ExsID.ToString();
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                sSQL = "update _BarCodeList set Used = 1 where BarCode = '" + model_BarCodeRD.BarCode + "'";
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                //当可用量为0是,标记条形码失效
                                sSQL = DAL_BarCodeList.sBarCodeQty(model_BarCodeRD.BarCode);
                                DataTable dtQty = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                                if (dtQty != null && dtQty.Rows.Count > 0)
                                {
                                    decimal dQtyUsed = BaseFunction.ReturnDecimal(dtQty.Rows[0][0]);
                                    if (dQtyUsed >= 0)
                                    {
                                        sSQL = "update _BarCodeList set valid = 1 where BarCode = '" + model_BarCodeRD.BarCode + "'";
                                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                    }
                                }
                            }
                        }
                    }



                    if (dQtyScanSum != 0)
                    {
                        throw new Exception("扫描数量未完全分配");
                    }
                    if (iCou == 0)
                    {
                        throw new Exception("没有语句执行");
                    }

                    #region 判断所有数量扫描后审核单据

                    sSQL = "select getdate()";
                    DataTable dTime    = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    DateTime  dTimeNow = ClsBaseDataInfo.ReturnObjectToDatetime(dTime.Rows[0][0]);
                    sSQL = @"
select case when sum(cast(isnull(b.cDefine31,0) as decimal(16,6))) <> sum(b.iQuantity ) then 1 else 0 end as iCou
from DispatchList a inner join DispatchLists b on a.dlid = b.dlid
where a.cDLCode = '111111' 
group by a.cDLCode

";
                    //仓库不同,分多张出库单
                    sSQL = sSQL.Replace("111111", sCode);
                    DataTable dtTemp2 = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dtTemp2 != null && dtTemp2.Rows.Count == 1)
                    {
                        int iC = BaseFunction.ReturnInt(dtTemp2.Rows[0][0]);
                        if (iC == 0)
                        {
                            sSQL = @" 
Update DispatchList SET  cVerifier=N'222222',cChanger=null,dverifydate='333333' ,dverifysystime=getdate() 
WHERE DispatchList.cDLCode = '111111'
";
                            //sSQL = "update TransVouch set cVerifyPerson = '222222',dVerifyDate  = '333333',dnverifytime = getdate() where cTVCode = '111111'";
                            sSQL = sSQL.Replace("111111", sCode);
                            sSQL = sSQL.Replace("222222", sUid);
                            sSQL = sSQL.Replace("333333", dTimeNow.ToString("yyyy-MM-dd"));
                            DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                            sSQL = "select distinct b.cWhCode from  DispatchList a inner join DispatchLists b on a.dlid = b.dlid where a.cDLCode = '111111'";
                            sSQL = sSQL.Replace("111111", sCode);
                            DataTable dtcWhCode = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                            for (int ii = 0; ii < dtcWhCode.Rows.Count; ii++)
                            {
                                sSQL = @"
select *
from DispatchList a inner join DispatchLists b on a.dlid = b.dlid
where a.cDLCode = '111111' and b.cWhCode = '222222'
order by cWhCode ,autoid
";
                                sSQL = sSQL.Replace("111111", sDLCode);
                                sSQL = sSQL.Replace("222222", dtcWhCode.Rows[ii]["cWhCode"].ToString().Trim());
                                DataTable dtTran  = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                                int       iCouRow = dtTran.Rows.Count;

                                #region 生成销售出库单据
                                //获得单据号
                                sSQL = "select cNumber from VoucherHistory Where CardNumber='0303' and cSeed = '" + dTimeNow.ToString("yyyyMM") + "'";
                                DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                                long lCode = 0;
                                if (dt != null && dt.Rows.Count > 0)
                                {
                                    lCode  = BaseFunction.ReturnLong(dt.Rows[0]["cNumber"]);
                                    lCode += 1;
                                    sSQL   = "update  VoucherHistory set cNumber = '" + lCode.ToString() + "' Where CardNumber='0303'  and cSeed = '" + dTimeNow.ToString("yyyyMM") + "'";
                                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                }
                                else
                                {
                                    lCode = 1;
                                    sSQL  = "insert into VoucherHistory(CardNumber,cContent,cContentRule,cSeed,cNumber,bEmpty)" +
                                            "values('0303','日期','月','" + dTimeNow.ToString("yyyyMM") + "','1',0)";
                                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                }
                                sCode = lCode.ToString();
                                while (sCode.Length < 5)
                                {
                                    sCode = "0" + sCode;
                                }

                                sCode = "XC" + dTimeNow.ToString("yyMM") + sCode;

                                long lID        = 0;
                                long lIDDetails = 0;


                                sSQL = @"
declare @p5 int
set @p5=111111
declare @p6 int
set @p6=222222
exec sp_GetId N'',N'444444',N'rd',333333,@p5 output,@p6 output,default
select @p5, @p6
";
                                sSQL = sSQL.Replace("111111", lID.ToString());
                                sSQL = sSQL.Replace("222222", lIDDetails.ToString());
                                sSQL = sSQL.Replace("333333", iCouRow.ToString());
                                sSQL = sSQL.Replace("444444", sAccID);
                                dt   = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                                lID        = ClsBaseDataInfo.ReturnObjectToLong(dt.Rows[0][0]) - 1;
                                lIDDetails = ClsBaseDataInfo.ReturnObjectToLong(dt.Rows[0][1]) - iCouRow;

                                lID += 1;
                                Model.RdRecord32 modelr32 = new TH.WebService.Model.RdRecord32();
                                modelr32.ID          = lID;
                                modelr32.bRdFlag     = 1;
                                modelr32.cVouchType  = "32";
                                modelr32.cBusType    = "普通销售";
                                modelr32.cSource     = "发货单";
                                modelr32.cBusCode    = sDLCode;
                                modelr32.cWhCode     = dtTran.Rows[0]["cWhCode"].ToString().Trim();
                                modelr32.dDate       = BaseFunction.ReturnDate(dTimeNow.ToString("yyyy-MM-dd"));
                                modelr32.cCode       = sCode;
                                modelr32.cRdCode     = dtTran.Rows[0]["cRdCode"].ToString().Trim();
                                modelr32.cDepCode    = dtTran.Rows[0]["cDepCode"].ToString().Trim();
                                modelr32.cCusCode    = dtTran.Rows[0]["cCusCode"].ToString().Trim();
                                modelr32.cPersonCode = dtTran.Rows[0]["cPersonCode"].ToString().Trim();
                                modelr32.cSTCode     = dtTran.Rows[0]["cSTCode"].ToString().Trim();
                                modelr32.cDLCode     = TH.WebService.BaseClass.ClsBaseDataInfo.ReturnObjectToLong(dtTran.Rows[0]["DLID"]);


                                modelr32.bTransFlag       = false;
                                modelr32.cMaker           = sUid;
                                modelr32.bpufirst         = false;
                                modelr32.biafirst         = false;
                                modelr32.VT_ID            = 327;
                                modelr32.bIsSTQc          = false;
                                modelr32.bOMFirst         = false;
                                modelr32.bFromPreYear     = false;
                                modelr32.bIsComplement    = 0;
                                modelr32.iDiscountTaxType = 0;
                                modelr32.ireturncount     = 0;
                                modelr32.iverifystate     = 0;
                                modelr32.iswfcontrolled   = 0;
                                modelr32.dnmaketime       = dTimeNow;
                                modelr32.bredvouch        = 0;

                                DAL.rdrecord32 DALr32 = new rdrecord32();
                                sSQL = DALr32.Add(modelr32);
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                for (int i = 0; i < dtTran.Rows.Count; i++)
                                {
                                    Model.RdRecords32 modelr32s = new TH.WebService.Model.RdRecords32();

                                    lIDDetails         += 1;
                                    modelr32s.AutoID    = lIDDetails;
                                    modelr32s.ID        = lID;
                                    modelr32s.cInvCode  = dtTran.Rows[i]["cInvCode"].ToString().Trim();
                                    modelr32s.iQuantity = BaseFunction.ReturnDecimal(dtTran.Rows[i]["iQuantity"]);
                                    modelr32s.iNum      = BaseFunction.ReturnDecimal(dtTran.Rows[i]["iNum"]);
                                    modelr32s.irowno    = BaseFunction.ReturnInt(dtTran.Rows[i]["irowno"]);
                                    modelr32s.iDLsID    = BaseFunction.ReturnLong(dtTran.Rows[i]["iDLsID"]);

                                    DAL.rdrecords32 DALr32s = new rdrecords32();
                                    sSQL = DALr32s.Add(modelr32s);
                                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                    sSQL = "insert into IA_ST_UnAccountVouch32(idun,idsun,cvoutypeun,cbustypeun)values " +
                                           "('" + lID + "','" + lIDDetails + "','32','调拨入库')";
                                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                                }
                                #endregion

                                //回写发货数量
                                sSQL = "update dispatchlists with (UPDLOCK) set fOutQuantity=iQuantity, fOutNum=iNum where DLID = " + dtTran.Rows[0]["DLID"].ToString().Trim();
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                                //回写发货单表头
                                sSQL = " Update DispatchList SET cSaleOut=N'" + sCode + "' WHERE DispatchList.cDLCode ='" + sDLCode + "'";
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                            }
                        }
                        //sSQL = "exec SP_ClearCurrentStock_ST";
                        //DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }
                    #endregion

                    tran.Commit();
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                throw new Exception(ee.Message);
            }
            return(iCou);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(TH.WebService.Model.RdRecords32 model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.AutoID != null)
            {
                strSql1.Append("AutoID,");
                strSql2.Append("" + model.AutoID + ",");
            }
            if (model.ID != null)
            {
                strSql1.Append("ID,");
                strSql2.Append("" + model.ID + ",");
            }
            if (model.cInvCode != null)
            {
                strSql1.Append("cInvCode,");
                strSql2.Append("'" + model.cInvCode + "',");
            }
            if (model.iNum != null)
            {
                strSql1.Append("iNum,");
                strSql2.Append("" + model.iNum + ",");
            }
            if (model.iQuantity != null)
            {
                strSql1.Append("iQuantity,");
                strSql2.Append("" + model.iQuantity + ",");
            }
            if (model.iUnitCost != null)
            {
                strSql1.Append("iUnitCost,");
                strSql2.Append("" + model.iUnitCost + ",");
            }
            if (model.iPrice != null)
            {
                strSql1.Append("iPrice,");
                strSql2.Append("" + model.iPrice + ",");
            }
            if (model.iAPrice != null)
            {
                strSql1.Append("iAPrice,");
                strSql2.Append("" + model.iAPrice + ",");
            }
            if (model.iPUnitCost != null)
            {
                strSql1.Append("iPUnitCost,");
                strSql2.Append("" + model.iPUnitCost + ",");
            }
            if (model.iPPrice != null)
            {
                strSql1.Append("iPPrice,");
                strSql2.Append("" + model.iPPrice + ",");
            }
            if (model.cBatch != null)
            {
                strSql1.Append("cBatch,");
                strSql2.Append("'" + model.cBatch + "',");
            }
            if (model.cVouchCode != null)
            {
                strSql1.Append("cVouchCode,");
                strSql2.Append("" + model.cVouchCode + ",");
            }
            if (model.cInVouchCode != null)
            {
                strSql1.Append("cInVouchCode,");
                strSql2.Append("'" + model.cInVouchCode + "',");
            }
            if (model.cinvouchtype != null)
            {
                strSql1.Append("cinvouchtype,");
                strSql2.Append("'" + model.cinvouchtype + "',");
            }
            if (model.iSOutQuantity != null)
            {
                strSql1.Append("iSOutQuantity,");
                strSql2.Append("" + model.iSOutQuantity + ",");
            }
            if (model.iSOutNum != null)
            {
                strSql1.Append("iSOutNum,");
                strSql2.Append("" + model.iSOutNum + ",");
            }
            if (model.coutvouchid != null)
            {
                strSql1.Append("coutvouchid,");
                strSql2.Append("" + model.coutvouchid + ",");
            }
            if (model.coutvouchtype != null)
            {
                strSql1.Append("coutvouchtype,");
                strSql2.Append("'" + model.coutvouchtype + "',");
            }
            if (model.iSRedOutQuantity != null)
            {
                strSql1.Append("iSRedOutQuantity,");
                strSql2.Append("" + model.iSRedOutQuantity + ",");
            }
            if (model.iSRedOutNum != null)
            {
                strSql1.Append("iSRedOutNum,");
                strSql2.Append("" + model.iSRedOutNum + ",");
            }
            if (model.cFree1 != null)
            {
                strSql1.Append("cFree1,");
                strSql2.Append("'" + model.cFree1 + "',");
            }
            if (model.cFree2 != null)
            {
                strSql1.Append("cFree2,");
                strSql2.Append("'" + model.cFree2 + "',");
            }
            if (model.iFlag != null)
            {
                strSql1.Append("iFlag,");
                strSql2.Append("" + model.iFlag + ",");
            }
            if (model.iFNum != null)
            {
                strSql1.Append("iFNum,");
                strSql2.Append("" + model.iFNum + ",");
            }
            if (model.iFQuantity != null)
            {
                strSql1.Append("iFQuantity,");
                strSql2.Append("" + model.iFQuantity + ",");
            }
            if (model.dVDate != null)
            {
                strSql1.Append("dVDate,");
                strSql2.Append("'" + model.dVDate + "',");
            }
            if (model.cPosition != null)
            {
                strSql1.Append("cPosition,");
                strSql2.Append("'" + model.cPosition + "',");
            }
            if (model.cDefine22 != null)
            {
                strSql1.Append("cDefine22,");
                strSql2.Append("'" + model.cDefine22 + "',");
            }
            if (model.cDefine23 != null)
            {
                strSql1.Append("cDefine23,");
                strSql2.Append("'" + model.cDefine23 + "',");
            }
            if (model.cDefine24 != null)
            {
                strSql1.Append("cDefine24,");
                strSql2.Append("'" + model.cDefine24 + "',");
            }
            if (model.cDefine25 != null)
            {
                strSql1.Append("cDefine25,");
                strSql2.Append("'" + model.cDefine25 + "',");
            }
            if (model.cDefine26 != null)
            {
                strSql1.Append("cDefine26,");
                strSql2.Append("" + model.cDefine26 + ",");
            }
            if (model.cDefine27 != null)
            {
                strSql1.Append("cDefine27,");
                strSql2.Append("" + model.cDefine27 + ",");
            }
            if (model.cItem_class != null)
            {
                strSql1.Append("cItem_class,");
                strSql2.Append("'" + model.cItem_class + "',");
            }
            if (model.cItemCode != null)
            {
                strSql1.Append("cItemCode,");
                strSql2.Append("'" + model.cItemCode + "',");
            }
            if (model.iDLsID != null)
            {
                strSql1.Append("iDLsID,");
                strSql2.Append("" + model.iDLsID + ",");
            }
            if (model.iSBsID != null)
            {
                strSql1.Append("iSBsID,");
                strSql2.Append("" + model.iSBsID + ",");
            }
            if (model.iSendQuantity != null)
            {
                strSql1.Append("iSendQuantity,");
                strSql2.Append("" + model.iSendQuantity + ",");
            }
            if (model.iSendNum != null)
            {
                strSql1.Append("iSendNum,");
                strSql2.Append("" + model.iSendNum + ",");
            }
            if (model.iEnsID != null)
            {
                strSql1.Append("iEnsID,");
                strSql2.Append("" + model.iEnsID + ",");
            }
            if (model.cName != null)
            {
                strSql1.Append("cName,");
                strSql2.Append("'" + model.cName + "',");
            }
            if (model.cItemCName != null)
            {
                strSql1.Append("cItemCName,");
                strSql2.Append("'" + model.cItemCName + "',");
            }
            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.cBarCode != null)
            {
                strSql1.Append("cBarCode,");
                strSql2.Append("'" + model.cBarCode + "',");
            }
            if (model.iNQuantity != null)
            {
                strSql1.Append("iNQuantity,");
                strSql2.Append("" + model.iNQuantity + ",");
            }
            if (model.iNNum != null)
            {
                strSql1.Append("iNNum,");
                strSql2.Append("" + model.iNNum + ",");
            }
            if (model.cAssUnit != null)
            {
                strSql1.Append("cAssUnit,");
                strSql2.Append("'" + model.cAssUnit + "',");
            }
            if (model.dMadeDate != null)
            {
                strSql1.Append("dMadeDate,");
                strSql2.Append("'" + model.dMadeDate + "',");
            }
            if (model.iMassDate != null)
            {
                strSql1.Append("iMassDate,");
                strSql2.Append("" + model.iMassDate + ",");
            }
            if (model.cDefine28 != null)
            {
                strSql1.Append("cDefine28,");
                strSql2.Append("'" + model.cDefine28 + "',");
            }
            if (model.cDefine29 != null)
            {
                strSql1.Append("cDefine29,");
                strSql2.Append("'" + model.cDefine29 + "',");
            }
            if (model.cDefine30 != null)
            {
                strSql1.Append("cDefine30,");
                strSql2.Append("'" + model.cDefine30 + "',");
            }
            if (model.cDefine31 != null)
            {
                strSql1.Append("cDefine31,");
                strSql2.Append("'" + model.cDefine31 + "',");
            }
            if (model.cDefine32 != null)
            {
                strSql1.Append("cDefine32,");
                strSql2.Append("'" + model.cDefine32 + "',");
            }
            if (model.cDefine33 != null)
            {
                strSql1.Append("cDefine33,");
                strSql2.Append("'" + model.cDefine33 + "',");
            }
            if (model.cDefine34 != null)
            {
                strSql1.Append("cDefine34,");
                strSql2.Append("" + model.cDefine34 + ",");
            }
            if (model.cDefine35 != null)
            {
                strSql1.Append("cDefine35,");
                strSql2.Append("" + model.cDefine35 + ",");
            }
            if (model.cDefine36 != null)
            {
                strSql1.Append("cDefine36,");
                strSql2.Append("'" + model.cDefine36 + "',");
            }
            if (model.cDefine37 != null)
            {
                strSql1.Append("cDefine37,");
                strSql2.Append("'" + model.cDefine37 + "',");
            }
            if (model.iCheckIds != null)
            {
                strSql1.Append("iCheckIds,");
                strSql2.Append("" + model.iCheckIds + ",");
            }
            if (model.cBVencode != null)
            {
                strSql1.Append("cBVencode,");
                strSql2.Append("'" + model.cBVencode + "',");
            }
            if (model.bGsp != null)
            {
                strSql1.Append("bGsp,");
                strSql2.Append("" + (model.bGsp ? 1 : 0) + ",");
            }
            if (model.cGspState != null)
            {
                strSql1.Append("cGspState,");
                strSql2.Append("'" + model.cGspState + "',");
            }
            if (model.cCheckCode != null)
            {
                strSql1.Append("cCheckCode,");
                strSql2.Append("'" + model.cCheckCode + "',");
            }
            if (model.iCheckIdBaks != null)
            {
                strSql1.Append("iCheckIdBaks,");
                strSql2.Append("" + model.iCheckIdBaks + ",");
            }
            if (model.cRejectCode != null)
            {
                strSql1.Append("cRejectCode,");
                strSql2.Append("'" + model.cRejectCode + "',");
            }
            if (model.iRejectIds != null)
            {
                strSql1.Append("iRejectIds,");
                strSql2.Append("" + model.iRejectIds + ",");
            }
            if (model.cCheckPersonCode != null)
            {
                strSql1.Append("cCheckPersonCode,");
                strSql2.Append("'" + model.cCheckPersonCode + "',");
            }
            if (model.dCheckDate != null)
            {
                strSql1.Append("dCheckDate,");
                strSql2.Append("'" + model.dCheckDate + "',");
            }
            if (model.cMassUnit != null)
            {
                strSql1.Append("cMassUnit,");
                strSql2.Append("" + model.cMassUnit + ",");
            }
            if (model.iRefundInspectFlag != null)
            {
                strSql1.Append("iRefundInspectFlag,");
                strSql2.Append("" + model.iRefundInspectFlag + ",");
            }
            if (model.strContractId != null)
            {
                strSql1.Append("strContractId,");
                strSql2.Append("'" + model.strContractId + "',");
            }
            if (model.strCode != null)
            {
                strSql1.Append("strCode,");
                strSql2.Append("'" + model.strCode + "',");
            }
            if (model.bChecked != null)
            {
                strSql1.Append("bChecked,");
                strSql2.Append("" + (model.bChecked ? 1 : 0) + ",");
            }
            if (model.iEqDID != null)
            {
                strSql1.Append("iEqDID,");
                strSql2.Append("" + model.iEqDID + ",");
            }
            if (model.bLPUseFree != null)
            {
                strSql1.Append("bLPUseFree,");
                strSql2.Append("" + (model.bLPUseFree ? 1 : 0) + ",");
            }
            if (model.iRSRowNO != null)
            {
                strSql1.Append("iRSRowNO,");
                strSql2.Append("" + model.iRSRowNO + ",");
            }
            if (model.iOriTrackID != null)
            {
                strSql1.Append("iOriTrackID,");
                strSql2.Append("" + model.iOriTrackID + ",");
            }
            if (model.coritracktype != null)
            {
                strSql1.Append("coritracktype,");
                strSql2.Append("'" + model.coritracktype + "',");
            }
            if (model.cbaccounter != null)
            {
                strSql1.Append("cbaccounter,");
                strSql2.Append("'" + model.cbaccounter + "',");
            }
            if (model.dbKeepDate != null)
            {
                strSql1.Append("dbKeepDate,");
                strSql2.Append("'" + model.dbKeepDate + "',");
            }
            if (model.bCosting != null)
            {
                strSql1.Append("bCosting,");
                strSql2.Append("" + (model.bCosting ? 1 : 0) + ",");
            }
            if (model.bVMIUsed != null)
            {
                strSql1.Append("bVMIUsed,");
                strSql2.Append("" + (model.bVMIUsed ? 1 : 0) + ",");
            }
            if (model.iVMISettleQuantity != null)
            {
                strSql1.Append("iVMISettleQuantity,");
                strSql2.Append("" + model.iVMISettleQuantity + ",");
            }
            if (model.iVMISettleNum != null)
            {
                strSql1.Append("iVMISettleNum,");
                strSql2.Append("" + model.iVMISettleNum + ",");
            }
            if (model.cvmivencode != null)
            {
                strSql1.Append("cvmivencode,");
                strSql2.Append("'" + model.cvmivencode + "',");
            }
            if (model.iInvSNCount != null)
            {
                strSql1.Append("iInvSNCount,");
                strSql2.Append("" + model.iInvSNCount + ",");
            }
            if (model.cwhpersoncode != null)
            {
                strSql1.Append("cwhpersoncode,");
                strSql2.Append("'" + model.cwhpersoncode + "',");
            }
            if (model.cwhpersonname != null)
            {
                strSql1.Append("cwhpersonname,");
                strSql2.Append("'" + model.cwhpersonname + "',");
            }
            if (model.cserviceoid != null)
            {
                strSql1.Append("cserviceoid,");
                strSql2.Append("'" + model.cserviceoid + "',");
            }
            if (model.cbserviceoid != null)
            {
                strSql1.Append("cbserviceoid,");
                strSql2.Append("'" + model.cbserviceoid + "',");
            }
            if (model.iinvexchrate != null)
            {
                strSql1.Append("iinvexchrate,");
                strSql2.Append("" + model.iinvexchrate + ",");
            }
            if (model.cbdlcode != null)
            {
                strSql1.Append("cbdlcode,");
                strSql2.Append("'" + model.cbdlcode + "',");
            }
            if (model.corufts != null)
            {
                strSql1.Append("corufts,");
                strSql2.Append("'" + model.corufts + "',");
            }
            if (model.strContractGUID != null)
            {
                strSql1.Append("strContractGUID,");
                strSql2.Append("'" + Guid.NewGuid().ToString() + "',");
            }
            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.cciqbookcode != null)
            {
                strSql1.Append("cciqbookcode,");
                strSql2.Append("'" + model.cciqbookcode + "',");
            }
            if (model.iBondedSumQty != null)
            {
                strSql1.Append("iBondedSumQty,");
                strSql2.Append("" + model.iBondedSumQty + ",");
            }
            if (model.ccusinvcode != null)
            {
                strSql1.Append("ccusinvcode,");
                strSql2.Append("'" + model.ccusinvcode + "',");
            }
            if (model.ccusinvname != null)
            {
                strSql1.Append("ccusinvname,");
                strSql2.Append("'" + model.ccusinvname + "',");
            }
            if (model.iorderdid != null)
            {
                strSql1.Append("iorderdid,");
                strSql2.Append("" + model.iorderdid + ",");
            }
            if (model.iordertype != null)
            {
                strSql1.Append("iordertype,");
                strSql2.Append("" + model.iordertype + ",");
            }
            if (model.iordercode != null)
            {
                strSql1.Append("iordercode,");
                strSql2.Append("'" + model.iordercode + "',");
            }
            if (model.iorderseq != null)
            {
                strSql1.Append("iorderseq,");
                strSql2.Append("" + model.iorderseq + ",");
            }
            if (model.ipesodid != null)
            {
                strSql1.Append("ipesodid,");
                strSql2.Append("'" + model.ipesodid + "',");
            }
            if (model.ipesotype != null)
            {
                strSql1.Append("ipesotype,");
                strSql2.Append("" + model.ipesotype + ",");
            }
            if (model.cpesocode != null)
            {
                strSql1.Append("cpesocode,");
                strSql2.Append("'" + model.cpesocode + "',");
            }
            if (model.ipesoseq != null)
            {
                strSql1.Append("ipesoseq,");
                strSql2.Append("" + model.ipesoseq + ",");
            }
            if (model.isodid != null)
            {
                strSql1.Append("isodid,");
                strSql2.Append("'" + model.isodid + "',");
            }
            if (model.isotype != null)
            {
                strSql1.Append("isotype,");
                strSql2.Append("" + model.isotype + ",");
            }
            if (model.csocode != null)
            {
                strSql1.Append("csocode,");
                strSql2.Append("'" + model.csocode + "',");
            }
            if (model.isoseq != null)
            {
                strSql1.Append("isoseq,");
                strSql2.Append("" + model.isoseq + ",");
            }
            if (model.cBatchProperty1 != null)
            {
                strSql1.Append("cBatchProperty1,");
                strSql2.Append("" + model.cBatchProperty1 + ",");
            }
            if (model.cBatchProperty2 != null)
            {
                strSql1.Append("cBatchProperty2,");
                strSql2.Append("" + model.cBatchProperty2 + ",");
            }
            if (model.cBatchProperty3 != null)
            {
                strSql1.Append("cBatchProperty3,");
                strSql2.Append("" + model.cBatchProperty3 + ",");
            }
            if (model.cBatchProperty4 != null)
            {
                strSql1.Append("cBatchProperty4,");
                strSql2.Append("" + model.cBatchProperty4 + ",");
            }
            if (model.cBatchProperty5 != null)
            {
                strSql1.Append("cBatchProperty5,");
                strSql2.Append("" + model.cBatchProperty5 + ",");
            }
            if (model.cBatchProperty6 != null)
            {
                strSql1.Append("cBatchProperty6,");
                strSql2.Append("'" + model.cBatchProperty6 + "',");
            }
            if (model.cBatchProperty7 != null)
            {
                strSql1.Append("cBatchProperty7,");
                strSql2.Append("'" + model.cBatchProperty7 + "',");
            }
            if (model.cBatchProperty8 != null)
            {
                strSql1.Append("cBatchProperty8,");
                strSql2.Append("'" + model.cBatchProperty8 + "',");
            }
            if (model.cBatchProperty9 != null)
            {
                strSql1.Append("cBatchProperty9,");
                strSql2.Append("'" + model.cBatchProperty9 + "',");
            }
            if (model.cBatchProperty10 != null)
            {
                strSql1.Append("cBatchProperty10,");
                strSql2.Append("'" + model.cBatchProperty10 + "',");
            }
            if (model.cbMemo != null)
            {
                strSql1.Append("cbMemo,");
                strSql2.Append("'" + model.cbMemo + "',");
            }
            if (model.irowno != null)
            {
                strSql1.Append("irowno,");
                strSql2.Append("" + model.irowno + ",");
            }
            if (model.strowguid != null)
            {
                strSql1.Append("strowguid,");
                strSql2.Append("'" + Guid.NewGuid().ToString() + "',");
            }
            if (model.rowufts != null)
            {
                strSql1.Append("rowufts,");
                strSql2.Append("" + model.rowufts + ",");
            }
            if (model.ipreuseqty != null)
            {
                strSql1.Append("ipreuseqty,");
                strSql2.Append("" + model.ipreuseqty + ",");
            }
            if (model.ipreuseinum != null)
            {
                strSql1.Append("ipreuseinum,");
                strSql2.Append("" + model.ipreuseinum + ",");
            }
            if (model.iDebitIDs != null)
            {
                strSql1.Append("iDebitIDs,");
                strSql2.Append("" + model.iDebitIDs + ",");
            }
            if (model.fsettleqty != null)
            {
                strSql1.Append("fsettleqty,");
                strSql2.Append("" + model.fsettleqty + ",");
            }
            if (model.fretqtywkp != null)
            {
                strSql1.Append("fretqtywkp,");
                strSql2.Append("" + model.fretqtywkp + ",");
            }
            if (model.fretqtyykp != null)
            {
                strSql1.Append("fretqtyykp,");
                strSql2.Append("" + model.fretqtyykp + ",");
            }
            if (model.cbsysbarcode != null)
            {
                strSql1.Append("cbsysbarcode,");
                strSql2.Append("'" + model.cbsysbarcode + "',");
            }
            if (model.bIAcreatebill != null)
            {
                strSql1.Append("bIAcreatebill,");
                strSql2.Append("" + (model.bIAcreatebill ? 1 : 0) + ",");
            }
            if (model.bsaleoutcreatebill != null)
            {
                strSql1.Append("bsaleoutcreatebill,");
                strSql2.Append("" + (model.bsaleoutcreatebill ? 1 : 0) + ",");
            }
            if (model.isaleoutid != null)
            {
                strSql1.Append("isaleoutid,");
                strSql2.Append("" + model.isaleoutid + ",");
            }
            if (model.bneedbill != null)
            {
                strSql1.Append("bneedbill,");
                strSql2.Append("" + (model.bneedbill ? 1 : 0) + ",");
            }
            strSql.Append("insert into rdrecords32(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            return(strSql.ToString());
        }