Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(UFIDA.U8.UAP.CustomApp.ControlForm.Model.rdrecords01 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.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.dSDate != null)
            {
                strSql1.Append("dSDate,");
                strSql2.Append("'" + model.dSDate + "',");
            }
            if (model.iTax != null)
            {
                strSql1.Append("iTax,");
                strSql2.Append("" + model.iTax + ",");
            }
            if (model.iSQuantity != null)
            {
                strSql1.Append("iSQuantity,");
                strSql2.Append("" + model.iSQuantity + ",");
            }
            if (model.iSNum != null)
            {
                strSql1.Append("iSNum,");
                strSql2.Append("" + model.iSNum + ",");
            }
            if (model.iMoney != null)
            {
                strSql1.Append("iMoney,");
                strSql2.Append("" + model.iMoney + ",");
            }
            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.iPOsID != null)
            {
                strSql1.Append("iPOsID,");
                strSql2.Append("" + model.iPOsID + ",");
            }
            if (model.fACost != null)
            {
                strSql1.Append("fACost,");
                strSql2.Append("" + model.fACost + ",");
            }
            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.chVencode != null)
            {
                strSql1.Append("chVencode,");
                strSql2.Append("'" + model.chVencode + "',");
            }
            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.iArrsId != null)
            {
                strSql1.Append("iArrsId,");
                strSql2.Append("" + model.iArrsId + ",");
            }
            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.iOriTaxCost != null)
            {
                strSql1.Append("iOriTaxCost,");
                strSql2.Append("" + model.iOriTaxCost + ",");
            }
            if (model.iOriCost != null)
            {
                strSql1.Append("iOriCost,");
                strSql2.Append("" + model.iOriCost + ",");
            }
            if (model.iOriMoney != null)
            {
                strSql1.Append("iOriMoney,");
                strSql2.Append("" + model.iOriMoney + ",");
            }
            if (model.iOriTaxPrice != null)
            {
                strSql1.Append("iOriTaxPrice,");
                strSql2.Append("" + model.iOriTaxPrice + ",");
            }
            if (model.ioriSum != null)
            {
                strSql1.Append("ioriSum,");
                strSql2.Append("" + model.ioriSum + ",");
            }
            if (model.iTaxRate != null)
            {
                strSql1.Append("iTaxRate,");
                strSql2.Append("" + model.iTaxRate + ",");
            }
            if (model.iTaxPrice != null)
            {
                strSql1.Append("iTaxPrice,");
                strSql2.Append("" + model.iTaxPrice + ",");
            }
            if (model.iSum != null)
            {
                strSql1.Append("iSum,");
                strSql2.Append("" + model.iSum + ",");
            }
            if (model.bTaxCost != null)
            {
                strSql1.Append("bTaxCost,");
                strSql2.Append("" + (model.bTaxCost ? 1 : 0) + ",");
            }
            if (model.cPOID != null)
            {
                strSql1.Append("cPOID,");
                strSql2.Append("'" + model.cPOID + "',");
            }
            if (model.cMassUnit != null)
            {
                strSql1.Append("cMassUnit,");
                strSql2.Append("" + model.cMassUnit + ",");
            }
            if (model.iMaterialFee != null)
            {
                strSql1.Append("iMaterialFee,");
                strSql2.Append("" + model.iMaterialFee + ",");
            }
            if (model.iProcessCost != null)
            {
                strSql1.Append("iProcessCost,");
                strSql2.Append("" + model.iProcessCost + ",");
            }
            if (model.iProcessFee != null)
            {
                strSql1.Append("iProcessFee,");
                strSql2.Append("" + model.iProcessFee + ",");
            }
            if (model.dMSDate != null)
            {
                strSql1.Append("dMSDate,");
                strSql2.Append("'" + model.dMSDate + "',");
            }
            if (model.iSMaterialFee != null)
            {
                strSql1.Append("iSMaterialFee,");
                strSql2.Append("" + model.iSMaterialFee + ",");
            }
            if (model.iSProcessFee != null)
            {
                strSql1.Append("iSProcessFee,");
                strSql2.Append("" + model.iSProcessFee + ",");
            }
            if (model.iOMoDID != null)
            {
                strSql1.Append("iOMoDID,");
                strSql2.Append("" + model.iOMoDID + ",");
            }
            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.bRelated != null)
            {
                strSql1.Append("bRelated,");
                strSql2.Append("" + (model.bRelated ? 1 : 0) + ",");
            }
            if (model.iOMoMID != null)
            {
                strSql1.Append("iOMoMID,");
                strSql2.Append("" + model.iOMoMID + ",");
            }
            if (model.iMatSettleState != null)
            {
                strSql1.Append("iMatSettleState,");
                strSql2.Append("" + model.iMatSettleState + ",");
            }
            if (model.iBillSettleCount != null)
            {
                strSql1.Append("iBillSettleCount,");
                strSql2.Append("" + model.iBillSettleCount + ",");
            }
            if (model.bLPUseFree != null)
            {
                strSql1.Append("bLPUseFree,");
                strSql2.Append("" + (model.bLPUseFree ? 1 : 0) + ",");
            }
            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.iSumBillQuantity != null)
            {
                strSql1.Append("iSumBillQuantity,");
                strSql2.Append("" + model.iSumBillQuantity + ",");
            }
            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.impcost != null)
            {
                strSql1.Append("impcost,");
                strSql2.Append("" + model.impcost + ",");
            }

            //if (model.iIMBSID != null)
            //{
            //    strSql1.Append("iIMBSID,");
            //    strSql2.Append("" + model.iIMBSID + ",");
            //}
            if (model.cbarvcode != null)
            {
                strSql1.Append("cbarvcode,");
                strSql2.Append("'" + model.cbarvcode + "',");
            }
            if (model.dbarvdate != null)
            {
                strSql1.Append("dbarvdate,");
                strSql2.Append("'" + model.dbarvdate + "',");
            }
            if (model.iinvexchrate != null)
            {
                strSql1.Append("iinvexchrate,");
                strSql2.Append("" + model.iinvexchrate + ",");
            }
            if (model.corufts != null)
            {
                strSql1.Append("corufts,");
                strSql2.Append("'" + model.corufts + "',");
            }
            if (model.comcode != null)
            {
                strSql1.Append("comcode,");
                strSql2.Append("'" + model.comcode + "',");
            }
            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.iordertype != null)
            {
                strSql1.Append("iordertype,");
                strSql2.Append("" + model.iordertype + ",");
            }
            if (model.iorderdid != null)
            {
                strSql1.Append("iorderdid,");
                strSql2.Append("" + model.iorderdid + ",");
            }
            if (model.iordercode != null)
            {
                strSql1.Append("iordercode,");
                strSql2.Append("'" + model.iordercode + "',");
            }
            if (model.iorderseq != null)
            {
                strSql1.Append("iorderseq,");
                strSql2.Append("" + model.iorderseq + ",");
            }
            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.iFaQty != null)
            {
                strSql1.Append("iFaQty,");
                strSql2.Append("" + model.iFaQty + ",");
            }
            if (model.isTax != null)
            {
                strSql1.Append("isTax,");
                strSql2.Append("" + model.isTax + ",");
            }
            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.OutCopiedQuantity != null)
            {
                strSql1.Append("OutCopiedQuantity,");
                strSql2.Append("" + model.OutCopiedQuantity + ",");
            }
            if (model.iOldPartId != null)
            {
                strSql1.Append("iOldPartId,");
                strSql2.Append("" + model.iOldPartId + ",");
            }
            if (model.fOldQuantity != null)
            {
                strSql1.Append("fOldQuantity,");
                strSql2.Append("" + model.fOldQuantity + ",");
            }
            if (model.cbsysbarcode != null)
            {
                strSql1.Append("cbsysbarcode,");
                strSql2.Append("'" + model.cbsysbarcode + "',");
            }
            if (model.bmergecheck != null)
            {
                strSql1.Append("bmergecheck,");
                strSql2.Append("" + (model.bmergecheck ? 1 : 0) + ",");
            }
            if (model.iMergeCheckAutoId != null)
            {
                strSql1.Append("iMergeCheckAutoId,");
                strSql2.Append("" + model.iMergeCheckAutoId + ",");
            }
            if (model.bnoitemused != null)
            {
                strSql1.Append("bnoitemused,");
                strSql2.Append("" + model.bnoitemused + ",");
            }
            if (model.cReworkMOCode != null)
            {
                strSql1.Append("cReworkMOCode,");
                strSql2.Append("'" + model.cReworkMOCode + "',");
            }
            if (model.iReworkMODetailsid != null)
            {
                strSql1.Append("iReworkMODetailsid,");
                strSql2.Append("" + model.iReworkMODetailsid + ",");
            }
            if (model.iProductType != null)
            {
                strSql1.Append("iProductType,");
                strSql2.Append("" + model.iProductType + ",");
            }
            if (model.cMainInvCode != null)
            {
                strSql1.Append("cMainInvCode,");
                strSql2.Append("'" + model.cMainInvCode + "',");
            }
            if (model.iMainMoDetailsID != null)
            {
                strSql1.Append("iMainMoDetailsID,");
                strSql2.Append("" + model.iMainMoDetailsID + ",");
            }
            if (model.iShareMaterialFee != null)
            {
                strSql1.Append("iShareMaterialFee,");
                strSql2.Append("" + model.iShareMaterialFee + ",");
            }
            strSql.Append("insert into rdrecords01(");
            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());
        }
Esempio n. 2
0
        private void btnImprot_Click(object sender, EventArgs e)
        {
            try
            {
                gridViewPL.FocusedRowHandle -= 1;
                gridViewPL.FocusedRowHandle += 1;
            }
            catch { }

            try
            {
                if (txtCurrency.Text.Trim() == "")
                {
                    throw new Exception("Please set currency");
                }

                decimal dExch = BaseFunction.ReturnDecimal(txtExchangeRate.Text.Trim());
                if (dExch == 0)
                {
                    throw new Exception("Please set the exchange rate");
                }

                if (lookUpEditWarehouse.EditValue == null || lookUpEditWarehouse.Text.Trim() == "")
                {
                    lookUpEditWarehouse.Focus();
                    throw new Exception("Please choose warehouse");
                }

                int iCou = gridViewPL.RowCount;
                if (iCou == 0)
                {
                    throw new Exception("no data");
                }
                string        sErr   = "";
                int           iCount = 0;
                SqlConnection conn   = new SqlConnection(Conn);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();

                try
                {
                    DateTime dLogDate = BaseFunction.ReturnDate(sLogDate);

                    string sWhCode = lookUpEditWarehouse.Text.Trim();
                    string sRdCode = "101";

                    string    sSQL   = @"
select * from _Code where VouchType = 'RdRecord01'
";
                    DataTable dtCode = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dtCode != null && dtCode.Rows.Count > 0)
                    {
                        sRdCode = dtCode.Rows[0]["cRdCodeIn"].ToString().Trim();
                    }

                    //string sDate = dateEdit1.DateTime.ToString("yyyy-MM-dd");
                    string sDate = sLogDate;
                    sSQL = @"
select bflag_ST from gl_mend where iyear = aaaaaa and iperiod = bbbbbb
";
                    sSQL = sSQL.Replace("aaaaaa", dLogDate.Year.ToString());
                    sSQL = sSQL.Replace("bbbbbb", dLogDate.Month.ToString());
                    DataTable dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (BaseFunction.ReturnBool(dtTemp.Rows[0]["bflag_ST"]))
                    {
                        throw new Exception("The current date has been checked out");
                    }

                    string sDateTime = dateEditQuery.DateTime.ToString("yyyy-MM-dd");

//                    sSQL = @"
//select * from exch where cdate = 'aaaaaa'
//";
//                    sSQL = sSQL.Replace("aaaaaa", dtmBL.DateTime.ToString("yyyy.MM.dd"));
//                    DataTable dtExch = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
//                    if (dtExch == null || dtExch.Rows.Count == 0)
//                    {
//                        throw new Exception("Please set exchange rate");
//                    }

                    long lID  = 0;
                    long lIDs = 0;
                    sSQL   = @"
declare @p5 int
set @p5=0
declare @p6 int
set @p6=0
exec sp_GetId N'',N'@AccID',N'rd',@iCou,@p5 output,@p6 output,default
select @p5, @p6
";
                    sSQL   = sSQL.Replace("@iCou", iCou.ToString());
                    sSQL   = sSQL.Replace("@AccID", sAccID);
                    dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    lID    = BaseFunction.ReturnLong(dtTemp.Rows[0][0]);
                    lIDs   = BaseFunction.ReturnLong(dtTemp.Rows[0][1]) - iCou;

                    sSQL   = @"
select * From VoucherHistory  with (ROWLOCK)  Where  CardNumber='24' and cContent='日期' and cSeed='aaaaaa'
";
                    sSQL   = sSQL.Replace("aaaaaa", dLogDate.ToString("yyyyMMdd"));
                    dtTemp = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                    long iCode = 0;
                    if (dtTemp != null && dtTemp.Rows.Count > 0)
                    {
                        iCode = BaseFunction.ReturnLong(dtTemp.Rows[0]["cNumber"]) + 1;
                        sSQL  = @"
update VoucherHistory set cNumber = aaaaaa where autoid = bbbbbb and CardNumber = '24'
";
                        sSQL  = sSQL.Replace("aaaaaa", iCode.ToString());
                        sSQL  = sSQL.Replace("bbbbbb", dtTemp.Rows[0]["AutoId"].ToString().Trim());
                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }
                    else
                    {
                        iCode = 1;
                        sSQL  = @"
insert into VoucherHistory(CardNumber, cContent, cContentRule, cSeed, cNumber, bEmpty)
values('24','日期','日','aaaaaa',1,0)
";
                        sSQL  = sSQL.Replace("aaaaaa", dLogDate.ToString("yyyyMMdd"));
                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }

                    sSQL = @"
select * from PO_POMain where cPOID = 'aaaaaa'
";
                    sSQL = sSQL.Replace("aaaaaa", gridViewPL.GetRowCellValue(0, gridColPONO).ToString().Trim());
                    DataTable dtPO = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                    Model.RdRecord01 mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.RdRecord01();
                    mod.ID         = lID;
                    mod.bRdFlag    = 1;
                    mod.cVouchType = "01";
                    mod.cBusType   = "普通采购";
                    mod.cSource    = "采购订单";
                    //mod.cBusCode =
                    mod.cWhCode = sWhCode;               //在途仓库
                    mod.dDate   = dLogDate;

                    //DataRow[] drExch = dtExch.Select("cexch_name = '" + txtCurrency.Text.Trim() + "'");
                    //if (drExch.Length == 0)
                    //{
                    //    throw new Exception("Please set exchange rate");
                    //}
                    mod.iExchRate = dExch;

                    string sCode = iCode.ToString();
                    while (sCode.Length < 4)
                    {
                        sCode = "0" + sCode;
                    }
                    sCode        = "RC" + dLogDate.ToString("yyyyMMdd") + sCode;
                    mod.cCode    = sCode;
                    mod.cRdCode  = sRdCode;
                    mod.cDepCode = "LOG";
                    mod.cPTCode  = dtPO.Rows[0]["cPTCode"].ToString().Trim();
                    mod.cVenCode = dtPO.Rows[0]["cVenCode"].ToString().Trim();
                    //mod.cOrderCode = dtPO.Rows[0]["cPOID"].ToString().Trim();
                    mod.bTransFlag       = false;
                    mod.cMaker           = sUserName;
                    mod.cDefine10        = txtInvoiceNO.Text.Trim();
                    mod.bpufirst         = false;
                    mod.biafirst         = false;
                    mod.VT_ID            = 131313;
                    mod.bIsSTQc          = false;
                    mod.ipurorderid      = BaseFunction.ReturnLong(dtPO.Rows[0]["POID"]);
                    mod.iTaxRate         = BaseFunction.ReturnDecimal(dtPO.Rows[0]["iTaxRate"]);
                    mod.cExch_Name       = dtPO.Rows[0]["cExch_Name"].ToString().Trim();
                    mod.bOMFirst         = false;
                    mod.bFromPreYear     = false;
                    mod.bIsComplement    = 0;
                    mod.iDiscountTaxType = 0;
                    mod.ireturncount     = 0;
                    mod.iverifystate     = 0;
                    mod.iswfcontrolled   = 0;
                    mod.dnmaketime       = DateTime.Now;
                    mod.bredvouch        = 0;
                    mod.bCredit          = 0;
                    mod.iPrintCount      = 0;
                    mod.csysbarcode      = "||st01|" + mod.cCode;

                    mod.cDefine1  = txtBL.Text.Trim();
                    mod.cDefine10 = txtInvoiceNO.Text.Trim();

                    //导入单据审核
                    mod.dVeriDate    = mod.dDate;
                    mod.dnverifytime = DateTime.Now;
                    mod.cHandler     = mod.cMaker;

                    DAL.RdRecord01 dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.RdRecord01();
                    sSQL = dal.Add(mod);
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    for (int i = 0; i < gridViewPL.RowCount; i++)
                    {
                        if (!BaseFunction.ReturnBool(gridViewPL.GetRowCellValue(i, gridColSelected)))
                        {
                            continue;
                        }

                        //判断是否已经生成了采购入库单
                        long lRds01Autoid = BaseFunction.ReturnLong(gridViewPL.GetRowCellValue(i, gridColRds01ID));
                        if (lRds01Autoid > 0)
                        {
                            sSQL = @"
select autoid from Rdrecords01 where autoid = aaaaaaaa
";
                            sSQL = sSQL.Replace("aaaaaaaa", lRds01Autoid.ToString());
                            DataTable dtRds01 = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                            if (dtRds01 != null && dtRds01.Rows.Count > 0)
                            {
                                sErr = sErr + "Line " + (i + 1).ToString() + " is imported\n";
                                continue;
                            }
                        }

                        string sPONO    = gridViewPL.GetRowCellValue(i, gridColPONO).ToString().Trim();
                        string sInvCode = gridViewPL.GetRowCellValue(i, gridColPARTNO).ToString().Trim();

                        //同一个订单相同子件只能有一个
                        sSQL = @"
select a.cPOID,a.POID,a.cexch_name ,a.cPTCode,a.cVenCode ,a.cBusType ,a.cDepCode 
    ,b.ID,b.cInvCode,b.iQuantity,isnull(b.freceivedqty ,0) as freceivedqty ,b.irowno ,b.ivouchrowno ,isnull(b.fPoArrQuantity ,0) as fPoArrQuantity 
    ,isnull(b.iReceivedQTY ,0) as iReceivedQTY ,isnull(b.iInvQTY ,0) as iInvQTY ,b.iPerTaxRate ,isnull(b.iArrQTY ,0) as iArrQTY 
    ,b.iPerTaxRate 

from PO_Pomain a inner join PO_Podetails b on a.POID = b.POID
where a.cPOID = 'aaaaaa' and b.cInvCode = 'bbbbbb'
";
                        sSQL = sSQL.Replace("aaaaaa", sPONO);
                        sSQL = sSQL.Replace("bbbbbb", sInvCode);
                        DataTable dtPOs = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                        if (dtPOs == null || dtPOs.Rows.Count == 0)
                        {
                            throw new Exception("Not found the corresponding purchase order");
                        }

                        Model.rdrecords01 mods = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.rdrecords01();
                        lIDs         += 1;
                        mods.AutoID   = lIDs;
                        mods.ID       = mod.ID;
                        mods.cInvCode = sInvCode;

                        decimal dQty    = BaseFunction.ReturnDecimal(gridViewPL.GetRowCellValue(i, gridColQUANTITY));
                        decimal dPOQty  = BaseFunction.ReturnDecimal(dtPOs.Rows[0]["iQuantity"]);
                        decimal dArrQty = BaseFunction.ReturnDecimal(dtPOs.Rows[0]["iReceivedQTY"]);

                        mods.iTaxRate     = BaseFunction.ReturnDecimal(dtPOs.Rows[0]["iPerTaxRate"]);
                        mods.iQuantity    = dQty;
                        mods.iOriCost     = BaseFunction.ReturnDecimal(gridViewPL.GetRowCellValue(i, gridColUnitPrice)); //原币无税单价
                        mods.iOriTaxCost  = BaseFunction.ReturnDecimal(mods.iOriCost * (1 + mods.iTaxRate / 100));       //原币含税单价
                        mods.iOriMoney    = BaseFunction.ReturnDecimal(mods.iOriCost * mods.iQuantity, 2);               //原币无税金额
                        mods.ioriSum      = BaseFunction.ReturnDecimal(mods.iOriTaxCost * mods.iQuantity, 2);            //原币含税金额
                        mods.iOriTaxPrice = mods.ioriSum - mods.iOriMoney;                                               //税额

                        mods.iUnitCost = BaseFunction.ReturnDecimal(mods.iOriCost * mod.iExchRate);                      //单价
                        mods.iPrice    = BaseFunction.ReturnDecimal(mods.iUnitCost * dQty, 2);                           //金额
                        mods.iSum      = BaseFunction.ReturnDecimal(mods.ioriSum * mod.iExchRate, 2);                    //本币价税合计
                        mods.iTaxPrice = mods.iSum - mods.iPrice;                                                        //本币税额
                        mods.bTaxCost  = true;

                        mods.fACost  = mods.iUnitCost;                                                                  //暂估单价
                        mods.iAPrice = mods.iSum;                                                                       //暂估金额

                        mods.iMoney = 0;                                                                                //累计结算金额

                        mods.iFlag             = 0;
                        mods.iSQuantity        = 0;
                        mods.iSNum             = 0;
                        mods.iPOsID            = BaseFunction.ReturnLong(dtPOs.Rows[0]["ID"]);
                        mods.iNQuantity        = dQty;
                        mods.chVencode         = dtPOs.Rows[0]["cVenCode"].ToString().Trim();
                        mods.cPOID             = dtPOs.Rows[0]["cPOID"].ToString().Trim();
                        mods.iMatSettleState   = 0;
                        mods.iBillSettleCount  = 0;
                        mods.bLPUseFree        = false;
                        mods.iOriTrackID       = 0;
                        mods.bCosting          = true;
                        mods.iExpiratDateCalcu = 0;
                        mods.isotype           = 0;
                        mods.irowno            = i + 1;
                        mods.cbsysbarcode      = "||st01|" + mod.cCode + "|" + mods.irowno.ToString();
                        mods.cDefine22         = gridViewPL.GetRowCellValue(i, gridColCONTAINERNO).ToString().Trim();
                        mods.cDefine23         = gridViewPL.GetRowCellValue(i, gridColBOXNO).ToString().Trim();
                        mods.cDefine24         = gridViewPL.GetRowCellValue(i, gridColCASENO).ToString().Trim();
                        mods.cDefine25         = gridViewPL.GetRowCellValue(i, gridColGWKGS).ToString().Trim();
                        mods.cDefine28         = gridViewPL.GetRowCellValue(i, gridColNWKGS).ToString().Trim();

                        DAL.rdrecords01 dals = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.rdrecords01();
                        sSQL    = dals.Add(mods);
                        iCount += DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                        sSQL = @"
if exists
    (select * from  CurrentStock where cInvCode = '@cInvCode' and cWhCode = '@cWhCode'
        and isnull(cFree1,'') = @cFree1 
        and isnull(cFree2,'') = @cFree2
        and isnull(cFree3,'') = @cFree3
        and isnull(cFree4,'') = @cFree4
        and isnull(cFree5,'') = @cFree5
        and isnull(cFree6,'') = @cFree6
        and isnull(cFree7,'') = @cFree7
        and isnull(cFree8,'') = @cFree8
        and isnull(cFree9,'') = @cFree9
        and isnull(cFree10,'') = @cFree10
        and isnull(cBatch,'') = @cBatch 
    )
    update  CurrentStock set iQuantity = isnull(iQuantity,0) + @iQuantity  
    where cInvCode = '@cInvCode' and cWhCode = '@cWhCode' 
        and isnull(cFree1,'') = @cFree1 
        and isnull(cFree2,'') = @cFree2
        and isnull(cFree3,'') = @cFree3
        and isnull(cFree4,'') = @cFree4
        and isnull(cFree5,'') = @cFree5
        and isnull(cFree6,'') = @cFree6
        and isnull(cFree7,'') = @cFree7
        and isnull(cFree8,'') = @cFree8
        and isnull(cFree9,'') = @cFree9
        and isnull(cFree10,'') = @cFree10
        and isnull(cBatch,'') = @cBatch 
else 
    begin 
        declare @itemid varchar(20); 
        declare @iCount int;  
        select @iCount=count(itemid) from CurrentStock where cInvCode = '@cInvCode';
        if( @iCount > 0 )
	        select @itemid=itemid from CurrentStock where cInvCode = '@cInvCode';
        else  
            select @itemid=max(itemid+1) from CurrentStock  
            insert into CurrentStock(cWhCode,cInvCode,iQuantity,itemid, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10,cBatch,iSoDid)
            values('@cWhCode','@cInvCode', @iQuantity,isnull(@itemid,1), @cFree1, @cFree2, @cFree3, @cFree4, @cFree5, @cFree6, @cFree7, @cFree8, @cFree9, @cFree10,@cBatch,'') 
    end
";
                        sSQL = sSQL.Replace("@cInvCode", mods.cInvCode);
                        sSQL = sSQL.Replace("@cWhCode", mod.cWhCode);
                        sSQL = sSQL.Replace("@iQuantity", mods.iQuantity.ToString());
                        sSQL = sSQL.Replace("@iNum", mods.iNum.ToString());
                        sSQL = sSQL.Replace("@cFree10", mods.cFree10 == null ? "''" : "'" + mods.cFree10 + "'");
                        sSQL = sSQL.Replace("@cFree1", mods.cFree1 == null ? "''" : "'" + mods.cFree1 + "'");
                        sSQL = sSQL.Replace("@cFree2", mods.cFree2 == null ? "''" : "'" + mods.cFree2 + "'");
                        sSQL = sSQL.Replace("@cFree3", mods.cFree3 == null ? "''" : "'" + mods.cFree3 + "'");
                        sSQL = sSQL.Replace("@cFree4", mods.cFree4 == null ? "''" : "'" + mods.cFree4 + "'");
                        sSQL = sSQL.Replace("@cFree5", mods.cFree5 == null ? "''" : "'" + mods.cFree5 + "'");
                        sSQL = sSQL.Replace("@cFree6", mods.cFree6 == null ? "''" : "'" + mods.cFree6 + "'");
                        sSQL = sSQL.Replace("@cFree7", mods.cFree7 == null ? "''" : "'" + mods.cFree7 + "'");
                        sSQL = sSQL.Replace("@cFree8", mods.cFree8 == null ? "''" : "'" + mods.cFree8 + "'");
                        sSQL = sSQL.Replace("@cFree9", mods.cFree9 == null ? "''" : "'" + mods.cFree9 + "'");
                        sSQL = sSQL.Replace("@cBatch", mods.cBatch == null ? "''" : "'" + mods.cBatch + "'");
                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                        //回写导入中间表 Rdrecords10_Import
                        sSQL = @"
update RdRecords01_Import set Rds01ID = AAAAAA
WHERE AUTOID = BBBBBB
";
                        sSQL = sSQL.Replace("AAAAAA", mods.AutoID.ToString());
                        sSQL = sSQL.Replace("BBBBBB", gridViewPL.GetRowCellValue(i, gridColAutoID).ToString());
                        int iRet = DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        if (iRet != 1)
                        {
                            sErr = sErr + "Row " + (i + 1) + " update dl err\n";
                        }

                        //回写采购订单
                        sSQL = @"
update PO_Podetails set iReceivedQTY = isnull(iReceivedQTY,0) + aaaaaa
where ID = bbbbbb
";
                        sSQL = sSQL.Replace("aaaaaa", mods.iQuantity.ToString());
                        sSQL = sSQL.Replace("bbbbbb", mods.iPOsID.ToString());
                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }

                    sSQL = @"
exec ST_SaveForStock N'01',N'aaaaaa',1,0 ,1
";
                    sSQL = sSQL.Replace("aaaaaa", mod.ID.ToString());
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    sSQL = @"
exec ST_SaveForTrackStock N'01',N'aaaaaa', 0 ,1
";
                    sSQL = sSQL.Replace("aaaaaa", mod.ID.ToString());
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    sSQL = @"
exec IA_SP_WriteUnAccountVouchForST 'aaaaaa',N'01'
";
                    sSQL = sSQL.Replace("aaaaaa", mod.ID.ToString());
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    if (sErr != "")
                    {
                        throw new Exception(sErr);
                    }

                    if (iCount > 0)
                    {
                        tran.Commit();
                        MessageBox.Show("Success:" + mod.cCode);

                        SetTxtNull();
                    }
                    else
                    {
                        throw new Exception("Save failed,no data");
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox frm = new FrmMsgBox();
                frm.richTextBox1.Text = ee.Message;
                frm.ShowDialog();
            }
        }