Example #1
0
        /// <summary>
        /// 修改出貨方式 改自出 改寄倉 改調度
        /// </summary>
        /// <param name="deliver_id">出貨單號</param>
        /// <param name="detail_id"></param>
        /// <param name="product_mode">出貨方式</param>
        /// <returns></returns>
        public string ProductMode(string deliver_id, string detail_id, string product_mode)
        {
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connString);
            SerialDao serialDao = new SerialDao("");
            StringBuilder allsql = new StringBuilder();
            StringBuilder sql = new StringBuilder();
            int i = 0;
            System.Net.IPAddress[] addlist = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList;
            string ip = string.Empty;
            //ip = CommonFunction.GetClientIP();
            if (addlist.Length > 0)
            {
                ip = addlist[0].ToString();
            }
            int user_id = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                sql.AppendLine(@"SELECT od.item_vendor_id,od.product_freight_set,od.single_money,od.buy_num,os.order_id,os.slave_id ");
                sql.AppendFormat(@" from order_detail od LEFT JOIN order_slave os on od.slave_id=os.slave_id WHERE od.detail_id='{0}' limit 1;", detail_id);
                DataTable dt = _access.getDataTable(sql.ToString());
                allsql.Append(sql.ToString());
                sql.Clear();
                string freightset = string.Empty;
                string vendorid = string.Empty;
                string orderid = "0";
                string slaveid = "0";
                string itemvendorid = "0";
                string vendormap = "0";
                uint subtotal = 0;
                object ob;
                if (dt.Rows.Count > 0)
                {
                    switch (dt.Rows[0]["product_freight_set"].ToString())
                    {
                        case "1":
                        case "3":
                            freightset = "1";
                            break;
                        case "2":
                        case "4":
                        case "5":
                        case "6":
                            freightset = "2";
                            break;
                        default:
                            break;
                    }
                    if (freightset == "1")
                    {
                        vendormap = "2";//吉甲地統倉
                    }
                    else if (freightset == "2")
                    {
                        vendormap = "92";//吉甲地冷凍倉
                    }
                    if (!string.IsNullOrEmpty(dt.Rows[0]["single_money"].ToString()) && !string.IsNullOrEmpty(dt.Rows[0]["buy_num"].ToString()))
                    {
                        subtotal = uint.Parse(dt.Rows[0]["single_money"].ToString().Trim()) * uint.Parse(dt.Rows[0]["buy_num"].ToString().Trim());
                    }
                    orderid = dt.Rows[0]["order_id"].ToString();
                    slaveid = dt.Rows[0]["slave_id"].ToString();
                    itemvendorid = dt.Rows[0]["item_vendor_id"].ToString();
                }
                #region 對order_slave表和order_deta表的操作
                vendorid = product_mode == "2" ? vendormap : itemvendorid;
                sql.AppendFormat(@"SELECT slave_id from order_slave  where order_id='{0}' ", orderid);
                sql.AppendFormat(@" and vendor_id='{0}' and slave_status=2;", vendorid);
                mySqlCmd.CommandText = sql.ToString();
                string newslaveid = string.Empty;
                ob = mySqlCmd.ExecuteScalar();
                if (ob != null)
                {
                    newslaveid = ob.ToString();
                }
                allsql.Append(sql.ToString());
                sql.Clear();
                if (string.IsNullOrEmpty(newslaveid))
                {
                    mySqlCmd.CommandText = serialDao.Update(30); //order_slave
                    allsql.Append(mySqlCmd.CommandText);
                    newslaveid = mySqlCmd.ExecuteScalar().ToString();
                    OrderSlave os = new OrderSlave();
                    os.Slave_Id = uint.Parse(newslaveid);
                    os.Order_Id = (!string.IsNullOrEmpty(orderid)) ? uint.Parse(orderid) : 0;
                    os.Vendor_Id = (!string.IsNullOrEmpty(vendorid)) ? uint.Parse(vendorid) : 0;
                    os.Slave_Product_Subtotal = subtotal;
                    os.Slave_Amount = subtotal;
                    os.Slave_Status = 2;//待出貨
                    os.Slave_Updatedate = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString());
                    os.Slave_Ipfrom = ip;
                    sql.AppendFormat(@"INSERT into order_slave (slave_id,order_id,vendor_id,slave_freight_normal,slave_freight_low,");
                    sql.AppendFormat(@"slave_product_subtotal,slave_amount,slave_status,slave_note,slave_date_delivery,");
                    sql.AppendFormat(@"slave_date_cancel,slave_date_return,slave_date_close,account_status,slave_updatedate,slave_ipfrom)");
                    sql.AppendFormat(@" VALUES('{0}','{1}','{2}','{3}','{4}',", os.Slave_Id, os.Order_Id, os.Vendor_Id, os.Slave_Freight_Normal, os.Slave_Freight_Low);
                    sql.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}',", os.Slave_Product_Subtotal, os.Slave_Amount, os.Slave_Status, os.Slave_Note, os.Slave_Date_Delivery);
                    sql.AppendFormat(@"'{0}','{1}','{2}','{3}',", os.Slave_Date_Cancel, os.Slave_Date_Return, os.Slave_Date_Close, os.Account_Status == true ? 1 : 0);
                    sql.AppendFormat(@"'{0}','{1}');", os.Slave_Updatedate, os.Slave_Ipfrom);
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                }
                if (newslaveid != slaveid)
                {
                    sql.AppendFormat(@" update order_slave set slave_product_subtotal=slave_product_subtotal+{0},", subtotal);
                    sql.AppendFormat(@" slave_amount=slave_amount+{0},slave_updatedate='{1}',", subtotal, CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                    sql.AppendFormat(@" slave_ipfrom='{0}' where slave_id='{1}'; ", ip, newslaveid);
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                }
                //更新order_detail表的slave_id,product_mode字段
                sql.AppendFormat(@" update order_detail set slave_id='{0}',product_mode='{1}'", newslaveid, product_mode);
                sql.AppendFormat(@" where detail_id='{0}';", detail_id);
                mySqlCmd.CommandText = sql.ToString();
                i = mySqlCmd.ExecuteNonQuery();
                allsql.Append(sql.ToString());
                sql.Clear();
                if (newslaveid != slaveid)
                {
                    sql.AppendFormat(" select count(slave_id) from order_detail where slave_id='{0}';", slaveid);
                    mySqlCmd.CommandText = sql.ToString();
                    string count = mySqlCmd.ExecuteScalar().ToString();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    if (count == "0")
                    {
                        sql.AppendFormat(@" DELETE FROM order_slave where slave_id='{0}';", slaveid);
                        mySqlCmd.CommandText = sql.ToString();
                        i = mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                        sql.Clear();
                    }
                    else
                    {
                        sql.AppendFormat(@" update order_slave set slave_product_subtotal=slave_product_subtotal-{0},", subtotal);
                        sql.AppendFormat(@" slave_amount=slave_amount-{0},slave_updatedate='{1}',", subtotal, CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                        sql.AppendFormat(@" slave_ipfrom='{0}' where slave_id='{1}'; ", ip, slaveid);
                        mySqlCmd.CommandText = sql.ToString();
                        i = mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                        sql.Clear();
                    }
                }
                #endregion
                #region 對deliver_master表和deliver_detail表的操作
                sql.AppendLine(@"SELECT deliver_id,order_id,ticket_id,type,export_id,import_id,freight_set,delivery_status,");
                sql.AppendLine(@" delivery_name,delivery_mobile,delivery_phone,delivery_zip,delivery_address,delivery_store,delivery_code,");
                sql.AppendLine(@"delivery_freight_cost,delivery_date,sms_date,arrival_date,estimated_delivery_date,estimated_arrival_date,");
                sql.AppendLine(@"estimated_arrival_period,creator,verifier,created,modified,export_flag,data_chg,work_status");
                sql.AppendFormat(@" FROM deliver_master WHERE deliver_id='{0}' LIMIT 1;", deliver_id);
                // sql.AppendFormat(@" select * from deliver_master where deliver_id='{0}' limit 1;", deliver_id);
                List<DeliverMaster> store = _access.getDataTableForObj<DeliverMaster>(sql.ToString());
                DeliverMaster dm = new DeliverMaster();
                if (store.Count > 0)
                {
                    dm = store[0];
                }
                allsql.Append(sql.ToString());
                sql.Clear();
                string exportid = product_mode == "1" ? itemvendorid : vendormap;//是否是改自出
                string deliverytype = product_mode == "1" ? "2" : "1";
                sql.AppendFormat(@"SELECT deliver_id from deliver_master where ");
                sql.AppendFormat(@" order_id='{0}' and type='{1}' and export_id='{2}' and freight_set='{3}' ;", orderid, deliverytype, exportid, freightset);
                mySqlCmd.CommandText = sql.ToString();
                ob = mySqlCmd.ExecuteScalar();
                string newdeliverid = string.Empty;
                if (ob != null)
                {
                    newdeliverid = ob.ToString();
                }
                allsql.Append(sql.ToString());
                sql.Clear();
                if (string.IsNullOrEmpty(newdeliverid))
                {
                    mySqlCmd.CommandText = serialDao.Update(76); //deliver_master
                    allsql.Append(mySqlCmd.CommandText);
                    newdeliverid = mySqlCmd.ExecuteScalar().ToString();
                    dm.ticket_id = 0;
                    dm.type = uint.Parse(deliverytype);//出貨類別,1:統倉出貨,2:供應商自行出貨,3:供應商調度出貨,4:退貨,5:退貨瑕疵,6:瑕疵(目前數據中只有1和2兩種)
                    dm.export_id = int.Parse(exportid);
                    dm.import_id = 0;
                    dm.deliver_id = uint.Parse(newdeliverid);
                    dm.creator = user_id;
                    dm.verifier = user_id;
                    dm.created = DateTime.Now;
                    dm.modified = DateTime.Now;
                    sql.AppendFormat(@"INSERT INTO deliver_master (deliver_id,order_id,ticket_id,type,export_id,import_id,freight_set,");
                    sql.AppendFormat(@"delivery_status,delivery_name,delivery_mobile,delivery_phone,delivery_zip,");
                    sql.AppendFormat(@"delivery_address,delivery_store,delivery_code,delivery_freight_cost,");
                    //sql.AppendFormat(@"sms_date,arrival_date,estimated_delivery_date,estimated_arrival_date,estimated_arrival_period,");
                    sql.AppendFormat(@"estimated_arrival_period, ");
                    sql.AppendFormat(@"creator,verifier,created,modified,export_flag,data_chg,work_status)");
                    sql.AppendFormat(@" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',", dm.deliver_id, dm.order_id, dm.ticket_id, dm.type, dm.export_id, dm.import_id, dm.freight_set);
                    sql.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}',", dm.delivery_status, dm.delivery_name, dm.delivery_mobile, dm.delivery_phone, dm.delivery_zip);
                    sql.AppendFormat(@"'{0}','{1}','{2}','{3}',", dm.delivery_address, dm.delivery_store, dm.delivery_code, dm.delivery_freight_cost);
                    sql.AppendFormat(@"'{0}',", dm.estimated_arrival_period);
                    sql.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}','{5}','{6}');", dm.creator, dm.verifier, dm.created.ToString("yyyy-MM-dd HH:mm:ss"), dm.modified.ToString("yyyy-MM-dd HH:mm:ss"), dm.export_flag, dm.data_chg, dm.work_status);
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                }
                if (newdeliverid != deliver_id)
                {
                    sql.AppendFormat(@" update deliver_detail set deliver_id='{0}' ", newdeliverid);
                    sql.AppendFormat(@" where deliver_id='{0}' and detail_id='{1}';  ", deliver_id, detail_id);
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    sql.Append(Shrink(deliver_id));
                    if (sql.Length > 0)
                    {
                        mySqlCmd.CommandText = sql.ToString();
                        mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                        sql.Clear();
                    }
                }
                sql.AppendFormat(@" SELECT deliver_id from deliver_master WHERE order_id='{0}'", orderid);
                sql.AppendFormat(@" and type=101 and export_id='{0}' and freight_set='{1}';", itemvendorid, freightset);
                mySqlCmd.CommandText = sql.ToString();
                ob = mySqlCmd.ExecuteScalar();
                string deliver_101_id = string.Empty;
                if (ob != null)
                {
                    deliver_101_id = ob.ToString();
                }
                allsql.Append(sql.ToString());
                sql.Clear();
                //自出 寄倉
                if (product_mode == "1" || product_mode == "2")
                {
                    sql.AppendFormat(@" DELETE  FROM deliver_detail where deliver_id='{0}'", deliver_101_id);
                    sql.AppendFormat(@" and detail_id='{0}'; ", detail_id);
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    sql.Append(Shrink(deliver_101_id));
                    if (sql.Length > 0)
                    {
                        mySqlCmd.CommandText = sql.ToString();
                        mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                        sql.Clear();
                    }
                }
                else if (product_mode == "3")
                {
                    if (string.IsNullOrEmpty(deliver_101_id))
                    {
                        mySqlCmd.CommandText = serialDao.Update(76); //deliver_master
                        allsql.Append(mySqlCmd.CommandText);
                        deliver_101_id = mySqlCmd.ExecuteScalar().ToString();
                        //DeliverMaster dm = new DeliverMaster();
                        dm.ticket_id = 0;
                        dm.type = 101;
                        dm.export_id = int.Parse(itemvendorid);
                        dm.import_id = 0;
                        dm.deliver_id = uint.Parse(deliver_101_id);
                        dm.creator = user_id;
                        dm.verifier = user_id;
                        dm.created = DateTime.Now;
                        dm.modified = DateTime.Now;
                        sql.AppendFormat(@"INSERT INTO deliver_master (deliver_id,order_id,ticket_id,type,export_id,import_id,freight_set,");
                        sql.AppendFormat(@"delivery_status,delivery_name,delivery_mobile,delivery_phone,delivery_zip,");
                        sql.AppendFormat(@"delivery_address,delivery_store,delivery_code,delivery_freight_cost,");
                        //sql.AppendFormat(@"sms_date,arrival_date,estimated_delivery_date,estimated_arrival_date,estimated_arrival_period,");
                        sql.AppendFormat(@" estimated_arrival_period,");
                        sql.AppendFormat(@"creator,verifier,created,modified,export_flag,data_chg,work_status)");
                        sql.AppendFormat(@" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',", dm.deliver_id, dm.order_id, dm.ticket_id, dm.type, dm.export_id, dm.import_id, dm.freight_set);
                        sql.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}',", dm.delivery_status, dm.delivery_name, dm.delivery_mobile, dm.delivery_phone, dm.delivery_zip);
                        sql.AppendFormat(@"'{0}','{1}','{2}','{3}',", dm.delivery_address, dm.delivery_store, dm.delivery_code, dm.delivery_freight_cost);
                        sql.AppendFormat(@"'{0}',", dm.estimated_arrival_period);
                        sql.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}','{5}','{6}');", dm.creator, dm.verifier, dm.created.ToString("yyyy-MM-dd HH:mm:ss"), dm.modified.ToString("yyyy-MM-dd HH:mm:ss"), dm.export_flag, dm.data_chg, dm.work_status);
                        mySqlCmd.CommandText = sql.ToString();
                        i = mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                        sql.Clear();
                        DeliverDetail dd = new DeliverDetail();
                        dd.deliver_id = uint.Parse(deliver_101_id);
                        dd.detail_id = uint.Parse(detail_id);
                        sql.AppendFormat(@" INSERT INTO deliver_detail (deliver_id,detail_id,delivery_status)");
                        sql.AppendFormat(@" VALUES ('{0}','{1}','{2}');", dd.deliver_id, dd.detail_id, dd.delivery_status);
                        mySqlCmd.CommandText = sql.ToString();
                        i = mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                        sql.Clear();
                    }

                }

                #endregion
                mySqlCmd.Transaction.Commit();
                return newdeliverid;
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("DeliverDetailDao-->ProductMode-->" + ex.Message + sql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
        }
Example #2
0
        /// <summary>
        /// 拆分細項 
        /// </summary>
        /// <param name="deliver_id"></param>
        /// <param name="detail_id"></param>
        public bool SplitDetail(string deliver_id, string detail_id)
        {
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connString);
            SerialDao serialDao = new SerialDao("");
            StringBuilder sql = new StringBuilder();
            int i = 0;
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                sql.AppendLine(@"SELECT detail_id,slave_id,item_id,item_vendor_id,product_freight_set,product_mode,product_name,");
                sql.AppendLine(@"product_spec_name,single_cost,event_cost,single_price,single_money,deduct_bonus,");
                sql.AppendLine(@"deduct_welfare,deduct_happygo as sdeduct_happygo ,deduct_happygo_money as sdeduct_happygo_money,deduct_account,deduct_account_note,");
                sql.AppendLine(@"accumulated_bonus as saccumulated_bonus ,accumulated_happygo as saccumulated_happygo ,buy_num,detail_status,detail_note,item_code,");
                sql.AppendLine(@"arrival_status as rarrival_status,delay_till,lastmile_deliver_serial,lastmile_deliver_datetime,");
                sql.AppendLine(@"lastmile_deliver_agency,bag_check_money,channel_detail_id,combined_mode as scombined_mode,item_mode,parent_id as sparent_id,parent_name,");
                sql.AppendLine(@"parent_num,price_master_id,pack_id,sub_order_id,site_id,event_id,prepaid");
                sql.AppendFormat(@" FROM order_detail WHERE detail_id='{0}' LIMIT 1;", detail_id);

                //sql.AppendFormat(@" select * from order_detail where detail_id='{0}' limit 1 ;", detail_id);
                List<OrderDetail> store = _access.getDataTableForObj<OrderDetail>(sql.ToString());
                OrderDetail od = new OrderDetail();
                if (store.Count > 0)
                {
                    od = store[0];
                }
                if (od.Buy_Num < 2)
                {
                    throw new Exception();
                }
                od.Buy_Num = od.Buy_Num - 1;
                od.Deduct_Bonus = uint.Parse((od.Deduct_Bonus / od.Buy_Num * (od.Buy_Num - 1)).ToString("0"));
                od.Deduct_Welfare = uint.Parse((od.Deduct_Welfare / od.Buy_Num * (od.Buy_Num - 1)).ToString("0"));
                od.rdeduct_happygo = int.Parse((od.rdeduct_happygo / od.Buy_Num * (od.Buy_Num - 1)).ToString("0"));
                od.raccumulated_bonus = int.Parse((od.raccumulated_bonus / od.Buy_Num * (od.Buy_Num - 1)).ToString("0"));
                od.raccumulated_happygo = int.Parse((od.raccumulated_happygo / od.Buy_Num * (od.Buy_Num - 1)).ToString("0"));
                sql.AppendFormat(@" update order_detail set buy_num='{0}',deduct_bonus='{1}',", od.Buy_Num, od.Deduct_Bonus);
                sql.AppendFormat(@"deduct_welfare='{0}',deduct_happygo='{1}',accumulated_bonus='{2}',", od.Deduct_Welfare, od.rdeduct_happygo, od.raccumulated_bonus);
                sql.AppendFormat(@"accumulated_happygo='{0}' where detail_id='{1}';", od.raccumulated_happygo, detail_id);
                mySqlCmd.CommandText = sql.ToString();
                i = mySqlCmd.ExecuteNonQuery();
                sql.Clear();
                OrderDetail odd = new OrderDetail();
                if (store.Count > 0)
                {
                    odd = store[0];
                }
                mySqlCmd.CommandText = serialDao.Update(32); //order_detail
                odd.Detail_Id = uint.Parse(mySqlCmd.ExecuteScalar().ToString());
                odd.Buy_Num = 1;
                odd.Deduct_Bonus = odd.Deduct_Bonus - od.Deduct_Bonus;
                odd.Deduct_Welfare = odd.Deduct_Welfare - od.Deduct_Welfare;
                odd.rdeduct_happygo = odd.rdeduct_happygo - od.rdeduct_happygo;
                odd.raccumulated_bonus = odd.raccumulated_bonus - od.raccumulated_bonus;
                odd.raccumulated_happygo = odd.raccumulated_happygo - od.raccumulated_happygo;
                sql.AppendFormat(@"INSERT INTO order_detail");
                sql.AppendFormat(@" (detail_id,slave_id,item_id,item_vendor_id,product_freight_set,product_mode");
                sql.AppendFormat(@" ,product_name,product_spec_name,single_cost,event_cost,single_price");
                sql.AppendFormat(@",single_money,deduct_bonus,deduct_welfare ,deduct_happygo,deduct_happygo_money");
                sql.AppendFormat(@",deduct_account,deduct_account_note,accumulated_bonus,accumulated_happygo");
                sql.AppendFormat(@",buy_num,detail_status,detail_note ,item_code,arrival_status,delay_till");
                sql.AppendFormat(@",lastmile_deliver_serial,lastmile_deliver_datetime,lastmile_deliver_agency");
                sql.AppendFormat(@",bag_check_money,channel_detail_id,combined_mode,item_mode,parent_id");
                sql.AppendFormat(@",parent_name,parent_num,price_master_id,pack_id,sub_order_id");
                sql.AppendFormat(@",site_id,event_id,prepaid)");
                sql.AppendFormat(@" VALUES('{0}','{1}','{2}','{3}','{4}','{5}',", odd.Detail_Id, odd.Slave_Id, odd.Item_Id, odd.Item_Vendor_Id, odd.Product_Freight_Set, odd.Product_Mode);
                sql.AppendFormat(@" '{0}','{1}','{2}','{3}','{4}',", odd.Product_Name, odd.Product_Spec_Name, odd.Single_Cost, odd.Event_Cost, odd.Single_Price);
                sql.AppendFormat(@" '{0}','{1}','{2}','{3}','{4}',", odd.Single_Money, odd.Deduct_Bonus, odd.Deduct_Welfare, odd.rdeduct_happygo, odd.rdeduct_happygo_money);
                sql.AppendFormat(@" '{0}','{1}','{2}','{3}',", odd.Deduct_Account, odd.Deduct_Account_Note, odd.raccumulated_bonus, odd.raccumulated_happygo);
                sql.AppendFormat(@" '{0}','{1}','{2}','{3}','{4}','{5}',", odd.Buy_Num, odd.Detail_Status, odd.Detail_Note, odd.Item_Code, odd.rarrival_status, odd.Delay_Till);
                sql.AppendFormat(@" '{0}','{1}','{2}',", odd.Lastmile_Deliver_Serial, odd.Lastmile_Deliver_Datetime, odd.Lastmile_Deliver_Agency);
                sql.AppendFormat(@" '{0}','{1}','{2}','{3}','{4}',", odd.Bag_Check_Money, odd.Channel_Detail_Id, odd.rcombined_mode, odd.item_mode, odd.rparent_id);
                sql.AppendFormat(@" '{0}','{1}','{2}','{3}','{4}',", odd.parent_name, odd.parent_num, odd.price_master_id, odd.pack_id, odd.Sub_Order_Id);
                sql.AppendFormat(@" '{0}','{1}','{2}')", odd.Site_Id, odd.event_id, odd.Prepaid);
                mySqlCmd.CommandText = sql.ToString();
                i = mySqlCmd.ExecuteNonQuery();
                sql.Clear();
                DeliverDetail dd = new DeliverDetail();
                dd.detail_id = odd.Detail_Id;
                sql.AppendFormat(@" insert into deliver_detail (deliver_id, detail_id) ");
                sql.AppendFormat(@" select deliver_id,{0} from deliver_detail where detail_id='{1}';", dd.detail_id, detail_id);
                mySqlCmd.CommandText = sql.ToString();
                i = mySqlCmd.ExecuteNonQuery();
                mySqlCmd.Transaction.Commit();
                return true;
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                return false;
                throw new Exception("DeliverDetailDao-->SplitDetail-->" + ex.Message + sql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
        }
Example #3
0
 /// <summary>
 /// 新增deliver_detail數據
 /// </summary>
 /// <param name="dd">DeliverDetail對象</param>
 /// <returns>數據庫操作受影響行數</returns>
 public int Add(DeliverDetail dd)
 {
     StringBuilder sbSql = new StringBuilder();
     sbSql.AppendFormat(@"insert into deliver_detail(deliver_id,detail_id,delivery_status) values({0},{1},{2})", dd.deliver_id, dd.detail_id, dd.delivery_status);
     try
     {
         return _access.execCommand(sbSql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception(" DeliverMasterDao-->Add-->" + ex.Message + sbSql.ToString(), ex);
     }
 }