Exemple #1
0
        public static Saf20 AddItem(Saf20 saf20)
        {
            if (saf20 == null)
            {
                throw new ArgumentNullException("saf20");
            }

            var lastDocSeq = GetLastDocnoSeq(saf20.saf20115_docno_type, saf20.saf20115_docno_date);

            saf20.saf20115_docno_seq = ++lastDocSeq;

            saf20.saf20114_docno = saf20.saf20115_docno_type +
                                   saf20.saf20115_docno_date.ToString("yyyyMMdd") +
                                   saf20.saf20115_docno_seq;

            using (var conn = new SqlConnection {
                ConnectionString = MyConnStringList.AzureGoodeasy
            })
                using (var sqlCmd = conn.CreateCommand())
                {
                    conn.Open();
                    sqlCmd.CommandText = @"INSERT INTO [dbo].[saf20]
                                   ([saf2000_status]
                                   ,[saf2001_cuscode]
                                   ,[saf2002_serial]
                                   ,[saf2010_ord_name]
                                   ,[saf2011_ord_cell]
                                   ,[saf2012_ord_tel01]
                                   ,[saf2014_rec_name]
                                   ,[saf2015_rec_cell]
                                   ,[saf2016_rec_tel01]
                                   ,[saf2017_rec_tel02]
                                   ,[saf2018_rec_zip]
                                   ,[saf2019_rec_address]
                                   ,[saf2022_dis_demand]
                                   ,[saf2023_ship_date]
                                   ,[saf2024_ship_remark]
                                   ,[saf2025_ship_condi]
                                   ,[saf2026_ship_status]
                                   ,[saf2027_ship_no]
                                   ,[saf2028_fre_no]
                                   ,[saf2029_logis_no]
                                   ,[saf2030_logis_comp]
                                   ,[saf2038_inv_no]
                                   ,[saf2039_inv_date]
                                   ,[saf2040_ship_qty]
                                   ,[saf2041_ord_qty]
                                   ,[saf2043_cancel_qty]
                                   ,[saf2045_cost_sub]
                                   ,[saf2046_mana_fee]
                                   ,[saf2048_price_sub]
                                   ,[saf2049_paymt_date]
                                   ,[saf2050_paymt_way]
                                   ,[saf2051_paymt_status]
                                   ,[saf2068_vendor_no]
                                   ,[saf2069_vendor_name]
                                   ,[saf2075_check_d]
                                   ,[saf2076_cancel_d]
                                   ,[saf2084_deli_date]
                                   ,[saf2090_col_money]
                                   ,[remark]
                                   ,[adduser]
                                   ,[adddate]
                                   ,[moduser]
                                   ,[moddate]
                                   ,[saf20101_total_amt]
                                   ,[saf20102_incl_fee]
                                   ,[saf20103_sales_amt]
                                   ,[saf20104_freetax_amt]
                                   ,[saf20105_tax]
                                   ,[saf20106_total_amt]
                                   ,[saf20107_tax_id]
                                   ,[saf20108_inv_no_end]
                                   ,[saf20109_tax_class]
                                   ,[saf20110_printmark]
                                   ,[saf20111_cuscode]
                                   ,[saf20112_dis_rate]
                                   ,[saf20113_trn_type]
                                   ,[saf20114_docno]
                                   ,[saf20115_bcode]
                                   ,[saf20115_docno_type]
                                   ,[saf20115_docno_date]
                                   ,[saf20115_docno_seq]
                                   ,[saf20116_src_docno])
                             VALUES
                                   (@saf2000_status
                                   ,@saf2001_cuscode
                                   ,@saf2002_serial
                                   ,@saf2010_ord_name
                                   ,@saf2011_ord_cell
                                   ,@saf2012_ord_tel01
                                   ,@saf2014_rec_name
                                   ,@saf2015_rec_cell
                                   ,@saf2016_rec_tel01
                                   ,@saf2017_rec_tel02
                                   ,@saf2018_rec_zip
                                   ,@saf2019_rec_address
                                   ,@saf2022_dis_demand
                                   ,@saf2023_ship_date
                                   ,@saf2024_ship_remark
                                   ,@saf2025_ship_condi
                                   ,@saf2026_ship_status
                                   ,@saf2027_ship_no
                                   ,@saf2028_fre_no
                                   ,@saf2029_logis_no
                                   ,@saf2030_logis_comp
                                   ,@saf2038_inv_no
                                   ,@saf2039_inv_date
                                   ,@saf2040_ship_qty
                                   ,@saf2041_ord_qty
                                   ,@saf2043_cancel_qty
                                   ,@saf2045_cost_sub
                                   ,@saf2046_mana_fee
                                   ,@saf2048_price_sub
                                   ,@saf2049_paymt_date
                                   ,@saf2050_paymt_way
                                   ,@saf2051_paymt_status
                                   ,@saf2068_vendor_no
                                   ,@saf2069_vendor_name
                                   ,@saf2075_check_d
                                   ,@saf2076_cancel_d
                                   ,@saf2084_deli_date
                                   ,@saf2090_col_money
                                   ,@remark
                                   ,@adduser
                                   ,@adddate
                                   ,@moduser
                                   ,@moddate
                                   ,@saf20101_total_amt
                                   ,@saf20102_incl_fee
                                   ,@saf20103_sales_amt
                                   ,@saf20104_freetax_amt
                                   ,@saf20105_tax
                                   ,@saf20106_total_amt
                                   ,@saf20107_tax_id
                                   ,@saf20108_inv_no_end
                                   ,@saf20109_tax_class
                                   ,@saf20110_printmark
                                   ,@saf20111_cuscode
                                   ,@saf20112_dis_rate
                                   ,@saf20113_trn_type
                                   ,@saf20114_docno
                                   ,@saf20115_bcode
                                   ,@saf20115_docno_type
                                   ,@saf20115_docno_date
                                   ,@saf20115_docno_seq
                                   ,@saf20116_src_docno)";

                    sqlCmd.Parameters.AddWithValue("@saf2000_status", saf20.saf2000_status);
                    sqlCmd.Parameters.AddWithValue("@saf2001_cuscode", saf20.saf2001_cuscode);
                    sqlCmd.Parameters.AddWithValue("@saf2002_serial", saf20.saf2002_serial);
                    sqlCmd.Parameters.AddWithValue("@saf2010_ord_name", saf20.saf2010_ord_name);
                    sqlCmd.Parameters.AddWithValue("@saf2011_ord_cell", saf20.saf2011_ord_cell);
                    sqlCmd.Parameters.AddWithValue("@saf2012_ord_tel01", saf20.saf2012_ord_tel01);
                    sqlCmd.Parameters.AddWithValue("@saf2014_rec_name", saf20.saf2014_rec_name);
                    sqlCmd.Parameters.AddWithValue("@saf2015_rec_cell", saf20.saf2015_rec_cell);
                    sqlCmd.Parameters.AddWithValue("@saf2016_rec_tel01", saf20.saf2016_rec_tel01);
                    sqlCmd.Parameters.AddWithValue("@saf2017_rec_tel02", saf20.saf2017_rec_tel02);
                    sqlCmd.Parameters.AddWithValue("@saf2018_rec_zip", saf20.saf2018_rec_zip);
                    sqlCmd.Parameters.AddWithValue("@saf2019_rec_address", saf20.saf2019_rec_address);
                    sqlCmd.Parameters.AddWithValue("@saf2022_dis_demand", saf20.saf2022_dis_demand);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf2023_ship_date", saf20.saf2023_ship_date);
                    sqlCmd.Parameters.AddWithValue("@saf2024_ship_remark", saf20.saf2024_ship_remark);
                    sqlCmd.Parameters.AddWithValue("@saf2025_ship_condi", saf20.saf2025_ship_condi);
                    sqlCmd.Parameters.AddWithValue("@saf2026_ship_status", saf20.saf2026_ship_status);
                    sqlCmd.Parameters.AddWithValue("@saf2027_ship_no", saf20.saf2027_ship_no);
                    sqlCmd.Parameters.AddWithValue("@saf2028_fre_no", saf20.saf2028_fre_no);
                    sqlCmd.Parameters.AddWithValue("@saf2029_logis_no", saf20.saf2029_logis_no);
                    sqlCmd.Parameters.AddWithValue("@saf2030_logis_comp", saf20.saf2030_logis_comp);
                    sqlCmd.Parameters.AddWithValue("@saf2038_inv_no", saf20.saf2038_inv_no);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf2039_inv_date", saf20.saf2039_inv_date);
                    sqlCmd.Parameters.AddWithValue("@saf2040_ship_qty", saf20.saf2040_ship_qty);
                    sqlCmd.Parameters.AddWithValue("@saf2041_ord_qty", saf20.saf2041_ord_qty);
                    sqlCmd.Parameters.AddWithValue("@saf2043_cancel_qty", saf20.saf2043_cancel_qty);
                    sqlCmd.Parameters.AddWithValue("@saf2045_cost_sub", saf20.saf2045_cost_sub);
                    sqlCmd.Parameters.AddWithValue("@saf2046_mana_fee", saf20.saf2046_mana_fee);
                    sqlCmd.Parameters.AddWithValue("@saf2048_price_sub", saf20.saf2048_price_sub);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf2049_paymt_date", saf20.saf2049_paymt_date);
                    sqlCmd.Parameters.AddWithValue("@saf2050_paymt_way", saf20.saf2050_paymt_way);
                    sqlCmd.Parameters.AddWithValue("@saf2051_paymt_status", saf20.saf2051_paymt_status);
                    sqlCmd.Parameters.AddWithValue("@saf2068_vendor_no", saf20.saf2068_vendor_no);
                    sqlCmd.Parameters.AddWithValue("@saf2069_vendor_name", saf20.saf2069_vendor_name);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf2075_check_d", saf20.saf2075_check_d);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf2076_cancel_d", saf20.saf2076_cancel_d);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf2084_deli_date", saf20.saf2084_deli_date);
                    sqlCmd.Parameters.AddWithValue("@saf2090_col_money", saf20.saf2090_col_money);
                    sqlCmd.Parameters.AddWithValue("@remark", saf20.remark);
                    sqlCmd.Parameters.AddWithValue("@adduser", saf20.adduser);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@adddate", saf20.adddate);
                    sqlCmd.Parameters.AddWithValue("@moduser", saf20.moduser);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@moddate", saf20.moddate);
                    sqlCmd.Parameters.AddWithValue("@saf20101_total_amt", saf20.saf20101_total_amt);
                    sqlCmd.Parameters.AddWithValue("@saf20102_incl_fee", saf20.saf20102_incl_fee);
                    sqlCmd.Parameters.AddWithValue("@saf20103_sales_amt", saf20.saf20103_sales_amt);
                    sqlCmd.Parameters.AddWithValue("@saf20104_freetax_amt", saf20.saf20104_freetax_amt);
                    sqlCmd.Parameters.AddWithValue("@saf20105_tax", saf20.saf20105_tax);
                    sqlCmd.Parameters.AddWithValue("@saf20106_total_amt", saf20.saf20106_total_amt);
                    sqlCmd.Parameters.AddWithValue("@saf20107_tax_id", saf20.saf20107_tax_id);
                    sqlCmd.Parameters.AddWithValue("@saf20108_inv_no_end", saf20.saf20108_inv_no_end);
                    sqlCmd.Parameters.AddWithValue("@saf20109_tax_class", saf20.saf20109_tax_class);
                    sqlCmd.Parameters.AddWithValue("@saf20110_printmark", saf20.saf20110_printmark);
                    sqlCmd.Parameters.AddWithValue("@saf20111_cuscode", saf20.saf20111_cuscode);
                    sqlCmd.Parameters.AddWithValue("@saf20112_dis_rate", saf20.saf20112_dis_rate);
                    sqlCmd.Parameters.AddWithValue("@saf20113_trn_type", saf20.saf20113_trn_type);
                    sqlCmd.Parameters.AddWithValue("@saf20114_docno", saf20.saf20114_docno);
                    sqlCmd.Parameters.AddWithValue("@saf20115_bcode", saf20.saf20115_bcode);
                    sqlCmd.Parameters.AddWithValue("@saf20115_docno_type", saf20.saf20115_docno_type);
                    sqlCmd.Parameters.AddWithValueDatetimeSafe("@saf20115_docno_date", saf20.saf20115_docno_date);
                    sqlCmd.Parameters.AddWithValue("@saf20115_docno_seq", saf20.saf20115_docno_seq);
                    sqlCmd.Parameters.AddWithValue("@saf20116_src_docno", saf20.saf20116_src_docno);
                    int id = (int)sqlCmd.ExecuteScalar();
                    saf20.id = id;
                }
            return(saf20);
        }
Exemple #2
0
        public static List <Saf20a> AddItem(Saf20 saf20, List <Saf20a> saf20aList)
        {
            if (saf20aList == null || saf20aList.Count == 0)
            {
                throw new ArgumentNullException("saf20aList");
            }

            using (var conn = new SqlConnection {
                ConnectionString = MyConnStringList.AzureGoodeasy
            })
                using (var sqlCmd = conn.CreateCommand())
                {
                    conn.Open();
                    sqlCmd.CommandText = @"INSERT INTO [dbo].[saf20a]
                                           ([saf20a02_serial]
                                           ,[saf20a03_ord_no]
                                           ,[saf20a04_ord_date]
                                           ,[saf20a31_psname]
                                           ,[saf20a32_pname]
                                           ,[saf20a33_pspec]
                                           ,[saf20a34_ship_pname]
                                           ,[saf20a35_ptpye]
                                           ,[saf20a36_pcode_v]
                                           ,[saf20a37_pcode]
                                           ,[saf20a38_inv_no]
                                           ,[saf20a39_inv_date]
                                           ,[saf20a40_ship_qty]
                                           ,[saf20a41_ord_qty]
                                           ,[saf20a42_groups]
                                           ,[saf20a43_cancel_qty]
                                           ,[saf20a44_cost]
                                           ,[saf20a45_cost_sub]
                                           ,[saf20a46_mana_fee]
                                           ,[saf20a47_price]
                                           ,[saf20a48_price_sub]
                                           ,[saf20a86_tax_class]
                                           ,[saf20a87_gift_pnt]
                                           ,[saf20a88_gift_amt]
                                           ,[remark]
                                           ,[adduser]
                                           ,[adddate]
                                           ,[moduser]
                                           ,[moddate]
                                           ,[saf20a103_sales_amt]
                                           ,[saf20a104_freetax_amt]
                                           ,[saf20a105_tax]
                                           ,[saf20a106_price_ntax]
                                           ,[saf20a107_wherehouse]
                                           ,[saf20a108_dis_rate]
                                           ,[saf20a109_docno]
                                           ,[saf20a109_seq]
                                           ,[saf20a110_dis_amt])
                                     VALUES
                                           (@saf20a02_serial
                                           ,@saf20a03_ord_no
                                           ,@saf20a04_ord_date
                                           ,@saf20a31_psname
                                           ,@saf20a32_pname
                                           ,@saf20a33_pspec
                                           ,@saf20a34_ship_pname
                                           ,@saf20a35_ptpye
                                           ,@saf20a36_pcode_v
                                           ,@saf20a37_pcode
                                           ,@saf20a38_inv_no
                                           ,@saf20a39_inv_date
                                           ,@saf20a40_ship_qty
                                           ,@saf20a41_ord_qty
                                           ,@saf20a42_groups
                                           ,@saf20a43_cancel_qty
                                           ,@saf20a44_cost
                                           ,@saf20a45_cost_sub
                                           ,@saf20a46_mana_fee
                                           ,@saf20a47_price
                                           ,@saf20a48_price_sub
                                           ,@saf20a86_tax_class
                                           ,@saf20a87_gift_pnt
                                           ,@saf20a88_gift_amt
                                           ,@remark
                                           ,@adduser
                                           ,@adddate
                                           ,@moduser
                                           ,@moddate
                                           ,@saf20a103_sales_amt
                                           ,@saf20a104_freetax_amt
                                           ,@saf20a105_tax
                                           ,@saf20a106_price_ntax
                                           ,@saf20a107_wherehouse
                                           ,@saf20a108_dis_rate
                                           ,@saf20a109_docno
                                           ,@saf20a109_seq
                                           ,@saf20a110_dis_amt)";
                    foreach (var saf20a in saf20aList)
                    {
                        sqlCmd.Parameters.Clear();
                        sqlCmd.Parameters.AddWithValue("@saf20a02_serial", saf20.saf2002_serial);
                        sqlCmd.Parameters.AddWithValue("@saf20a03_ord_no", saf20a.saf20a03_ord_no);
                        sqlCmd.Parameters.AddWithValue("@saf20a04_ord_date", saf20a.saf20a04_ord_date);
                        sqlCmd.Parameters.AddWithValue("@saf20a31_psname", saf20a.saf20a31_psname);
                        sqlCmd.Parameters.AddWithValue("@saf20a32_pname", saf20a.saf20a32_pname);
                        sqlCmd.Parameters.AddWithValue("@saf20a33_pspec", saf20a.saf20a33_pspec);
                        sqlCmd.Parameters.AddWithValue("@saf20a34_ship_pname", saf20a.saf20a34_ship_pname);
                        sqlCmd.Parameters.AddWithValue("@saf20a35_ptpye", saf20a.saf20a35_ptpye);
                        sqlCmd.Parameters.AddWithValue("@saf20a36_pcode_v", saf20a.saf20a36_pcode_v);
                        sqlCmd.Parameters.AddWithValue("@saf20a37_pcode", saf20a.saf20a37_pcode);
                        sqlCmd.Parameters.AddWithValue("@saf20a38_inv_no", saf20a.saf20a38_inv_no);
                        sqlCmd.Parameters.AddWithValue("@saf20a39_inv_date", saf20a.saf20a39_inv_date);
                        sqlCmd.Parameters.AddWithValue("@saf20a40_ship_qty", saf20a.saf20a40_ship_qty);
                        sqlCmd.Parameters.AddWithValue("@saf20a41_ord_qty", saf20a.saf20a41_ord_qty);
                        sqlCmd.Parameters.AddWithValue("@saf20a42_groups", saf20a.saf20a42_groups);
                        sqlCmd.Parameters.AddWithValue("@saf20a43_cancel_qty", saf20a.saf20a43_cancel_qty);
                        sqlCmd.Parameters.AddWithValue("@saf20a44_cost", saf20a.saf20a44_cost);
                        sqlCmd.Parameters.AddWithValue("@saf20a45_cost_sub", saf20a.saf20a45_cost_sub);
                        sqlCmd.Parameters.AddWithValue("@saf20a46_mana_fee", saf20a.saf20a46_mana_fee);
                        sqlCmd.Parameters.AddWithValue("@saf20a47_price", saf20a.saf20a47_price);
                        sqlCmd.Parameters.AddWithValue("@saf20a48_price_sub", saf20a.saf20a48_price_sub);
                        sqlCmd.Parameters.AddWithValue("@saf20a86_tax_class", saf20a.saf20a86_tax_class);
                        sqlCmd.Parameters.AddWithValue("@saf20a87_gift_pnt", saf20a.saf20a87_gift_pnt);
                        sqlCmd.Parameters.AddWithValue("@saf20a88_gift_amt", saf20a.saf20a88_gift_amt);
                        sqlCmd.Parameters.AddWithValue("@remark", saf20a.remark);
                        sqlCmd.Parameters.AddWithValue("@adduser", saf20a.adduser);
                        sqlCmd.Parameters.AddWithValue("@adddate", saf20a.adddate);
                        sqlCmd.Parameters.AddWithValue("@moduser", saf20a.moduser);
                        sqlCmd.Parameters.AddWithValue("@moddate", saf20a.moddate);
                        sqlCmd.Parameters.AddWithValue("@saf20a103_sales_amt", saf20a.saf20a103_sales_amt);
                        sqlCmd.Parameters.AddWithValue("@saf20a104_freetax_amt", saf20a.saf20a104_freetax_amt);
                        sqlCmd.Parameters.AddWithValue("@saf20a105_tax", saf20a.saf20a105_tax);
                        sqlCmd.Parameters.AddWithValue("@saf20a106_price_ntax", saf20a.saf20a106_price_ntax);
                        sqlCmd.Parameters.AddWithValue("@saf20a107_wherehouse", saf20a.saf20a107_wherehouse);
                        sqlCmd.Parameters.AddWithValue("@saf20a108_dis_rate", saf20a.saf20a108_dis_rate);
                        sqlCmd.Parameters.AddWithValue("@saf20a109_docno", saf20a.saf20a109_docno);
                        sqlCmd.Parameters.AddWithValue("@saf20a109_seq", saf20a.saf20a109_seq);
                        sqlCmd.Parameters.AddWithValue("@saf20a110_dis_amt", saf20a.saf20a110_dis_amt);
                        int id = (int)sqlCmd.ExecuteScalar();
                        saf20a.Id = id;
                    }
                }

            return(saf20aList);
        }