public static String ConcreateInsertCommand(APPR_DO_DETAIL source) { StringBuilder sqlCommand = new StringBuilder("INSERT INTO APPR_DO_DETAIL"); sqlCommand.Append(" (REF_ACTIVITY,REF_PRODUCT_CODE,REF_ASSET_NO,REF_SERIAL_NO,STATUS,USER_ID,STATUS_APPROVED,REMARK_APPROVED,DATE_APPROVED,QTY_OUT,REF_SO_DOCTYPE,REF_SO_DOCNO,REF_SO_DOCDATE,REF_SO_DOCSEQ,ASSET_START,ASSET_END,DISCOUNT_BILL_AMOUNT,VAT_DISCOUNT_BILL,TYPE_TAX,CHECK_PM,REF_PROJECT,SHOW_DOC_DATE,PREMIUM_AMOUNT,PLAN_CODE,FUND_CODE,BRANCH_NO,SECTION,DOC_TYPE,DOC_NO,DOC_DATE,SEQUENCE,DESCRIPTION_HEADER,DESCRIPTION_DETAIL,PRODUCT_CODE,WAREHOUSE,LOT_NO,UNIT_CODE,QUANTITY_UNIT,PRICE,AMOUNT_BEFORE_DISCOUNT,DISCOUNT_PATTERN,DISCOUNT_AMOUNT,AMOUNT_BEFORE_VAT,VAT_AMOUNT,AMOUNT_AFTER_VAT,LEDGER_TYPE,CURRENCY_CODE,CUSTOMER_CODE) "); sqlCommand.Append(" Values ("); sqlCommand.Append("'" + BindValue(source.REF_ACTIVITY) + "' ,"); sqlCommand.Append("'" + BindValue(source.REF_PRODUCT_CODE) + "' ,"); sqlCommand.Append("'" + BindValue(source.REF_ASSET_NO) + "' ,"); sqlCommand.Append("'" + BindValue(source.REF_SERIAL_NO) + "' ,"); sqlCommand.Append("'" + BindValue(source.STATUS) + "' ,"); sqlCommand.Append("'" + BindValue(source.USER_ID) + "' ,"); sqlCommand.Append("'" + BindValue(source.STATUS_APPROVED) + "' ,"); sqlCommand.Append("'" + BindValue(source.REMARK_APPROVED) + "' ,"); sqlCommand.Append(BindValue(source.DATE_APPROVED) + " ,"); sqlCommand.Append(BindValue(source.QTY_OUT) + " ,"); sqlCommand.Append("'" + BindValue(source.REF_SO_DOCTYPE) + "' ,"); sqlCommand.Append("'" + BindValue(source.REF_SO_DOCNO) + "' ,"); sqlCommand.Append(BindValue(source.REF_SO_DOCDATE) + " ,"); sqlCommand.Append(BindValue(source.REF_SO_DOCSEQ) + " ,"); sqlCommand.Append("'" + BindValue(source.ASSET_START) + "' ,"); sqlCommand.Append("'" + BindValue(source.ASSET_END) + "' ,"); sqlCommand.Append(BindValue(source.DISCOUNT_BILL_AMOUNT) + " ,"); sqlCommand.Append(BindValue(source.VAT_DISCOUNT_BILL) + " ,"); sqlCommand.Append("'" + BindValue(source.TYPE_TAX) + "' ,"); sqlCommand.Append(BindValue(source.CHECK_PM) + " ,"); sqlCommand.Append("'" + BindValue(source.REF_PROJECT) + "' ,"); sqlCommand.Append(BindValue(source.SHOW_DOC_DATE) + ","); sqlCommand.Append(BindValue(source.PREMIUM_AMOUNT) + " ,"); sqlCommand.Append("'" + BindValue(source.PLAN_CODE) + "' ,"); sqlCommand.Append("'" + BindValue(source.FUND_CODE) + "' ,"); sqlCommand.Append(BindValue(source.BRANCH_NO) + " ,"); sqlCommand.Append("'" + BindValue(source.SECTION) + "' ,"); sqlCommand.Append("'" + BindValue(source.DOC_TYPE) + "' ,"); sqlCommand.Append("'" + BindValue(source.DOC_NO) + "' ,"); sqlCommand.Append(BindValue(source.DOC_DATE) + " ,"); sqlCommand.Append(BindValue(source.SEQUENCE) + " ,"); sqlCommand.Append("'" + BindValue(source.DESCRIPTION_HEADER) + "' ,"); sqlCommand.Append("'" + BindValue(source.DESCRIPTION_DETAIL) + "' ,"); sqlCommand.Append("'" + BindValue(source.PRODUCT_CODE) + "' ,"); sqlCommand.Append("'" + BindValue(source.WAREHOUSE) + "' ,"); sqlCommand.Append("'" + BindValue(source.LOT_NO) + "' ,"); sqlCommand.Append("'" + BindValue(source.UNIT_CODE) + "' ,"); sqlCommand.Append(BindValue(source.QUANTITY_UNIT) + " ,"); sqlCommand.Append(BindValue(source.PRICE) + " ,"); sqlCommand.Append(BindValue(source.AMOUNT_BEFORE_DISCOUNT) + " ,"); sqlCommand.Append("'" + BindValue(source.DISCOUNT_PATTERN) + "' ,"); sqlCommand.Append(BindValue(source.DISCOUNT_AMOUNT) + " ,"); sqlCommand.Append(BindValue(source.AMOUNT_BEFORE_VAT) + " ,"); sqlCommand.Append(BindValue(source.VAT_AMOUNT) + " ,"); sqlCommand.Append(BindValue(source.AMOUNT_AFTER_VAT) + " ,"); sqlCommand.Append("'" + BindValue(source.LEDGER_TYPE) + "' ,"); sqlCommand.Append("'" + BindValue(source.CURRENCY_CODE) + "' ,"); sqlCommand.Append("'" + BindValue(source.CUSTOMER_CODE) + "' )"); return(sqlCommand.ToString()); }
public void TestSelectDatabase() { APPR_DO_HEADER item = ctx.APPR_DO_HEADER.FirstOrDefault(); APPR_DO_DETAIL appr_do_details = ctx.APPR_DO_DETAIL.FirstOrDefault(); APPR_DO_ADDRESS appr_do_address = ctx.APPR_DO_ADDRESS.FirstOrDefault(); APPR_DO_REMARK appr_do_remark = ctx.APPR_DO_REMARK.FirstOrDefault(); APPR_RECEIVE_H appr_receive_h = ctx.APPR_RECEIVE_H.FirstOrDefault(); APPR_RECEIVE_DETAIL_D appr_receive_detail_d = ctx.APPR_RECEIVE_DETAIL_D.FirstOrDefault(); APPR_GL_HEADER appr_gl_header = ctx.APPR_GL_HEADER.FirstOrDefault(); APPR_GL_DETAIL appr_gl_detail = ctx.APPR_GL_DETAIL.FirstOrDefault(); APPR_DO_HEADER header = new APPR_DO_HEADER() { BRANCH_NO = 2, SECTION = item.SECTION, DOC_TYPE = item.DOC_TYPE, DOC_NO = "12122e35451790", DOC_DATE = item.DOC_DATE, DESCRIPTION = item.DESCRIPTION, AMOUNT_BEFORE_DISCOUNT = item.AMOUNT_BEFORE_DISCOUNT, DISCOUNT_CREDIT_PATTERN = item.DISCOUNT_CREDIT_PATTERN, DISCOUNT_CASH_PATTERN = item.DISCOUNT_CASH_PATTERN, DISCOUNT_CREDIT = item.DISCOUNT_CREDIT, DISCOUNT_CASH = item.DISCOUNT_CASH, AMOUNT_BEFORE_VAT = item.AMOUNT_BEFORE_VAT, VAT_RATE = item.VAT_RATE, VAT_AMOUNT = item.VAT_AMOUNT, TOTAL_AMOUNT = item.TOTAL_AMOUNT, LEDGER_TYPE = item.LEDGER_TYPE, EMP_CODE = item.EMP_CODE, CUSTOMER_CODE = item.CUSTOMER_CODE, CUSTOMER_CODE_SHIPTO = item.CUSTOMER_CODE_SHIPTO, REFER_TYPE = item.REFER_TYPE, REFER_NO = item.REFER_NO, REFER_DATE = item.REFER_DATE, LAST_LINE = item.LAST_LINE, REMARK = item.REMARK, STATUS = item.STATUS, USER_ID = item.USER_ID, TIME = item.TIME, REF_BUDGET = item.REF_BUDGET, REF_PROJECT = item.REF_PROJECT, BUD_ACCOUNT_CODE = item.BUD_ACCOUNT_CODE, REF_ACTIVITY = item.REF_ACTIVITY, STATUS_APPROVE = item.STATUS_APPROVE, REMARK_APPROVE = item.REMARK_APPROVE, DATE_APPROVED = item.DATE_APPROVED, BUD_YEAR = item.BUD_YEAR, PAYMENT_TERM = item.PAYMENT_TERM, DELIVERY_DATE = item.DELIVERY_DATE, DUEDATE = item.DUEDATE, TYPE_TAX = item.TYPE_TAX, PAY_TYPE = item.PAY_TYPE, INVOICE_TYPE = item.INVOICE_TYPE, MEMBER_CODE = item.MEMBER_CODE, SALE_TYPE = item.SALE_TYPE, PAY_CASH = item.PAY_CASH, PAY_OTHER = item.PAY_OTHER, PAY_DEPOSIT = item.PAY_DEPOSIT, TIME_PRINT = item.TIME_PRINT, DATE_UPDATE = item.DATE_UPDATE, AR_ACCOUNT = item.AR_ACCOUNT, SHOW_DOC_DATE = item.SHOW_DOC_DATE, TYPE_DISPOSE = item.TYPE_DISPOSE, PREMIUM_AMOUNT = item.PREMIUM_AMOUNT, PLAN_CODE = item.PLAN_CODE, FUND_CODE = item.FUND_CODE, }; ctx.APPR_DO_HEADER.AddObject(header); ctx.SaveChanges(); ctx.APPR_DO_HEADER.DeleteObject(header); ctx.SaveChanges(); //Assert.IsNotNull(header); Assert.IsNotNull(appr_do_details); Assert.IsNotNull(appr_do_address); Assert.IsNotNull(appr_do_remark); Assert.IsNotNull(appr_receive_h); Assert.IsNotNull(appr_receive_detail_d); Assert.IsNotNull(appr_gl_header); Assert.IsNotNull(appr_gl_detail); }