예제 #1
0
        /// <summary>
        /// 下一次出貨
        /// </summary>
        /// <param name="deliver_id"></param>
        /// <param name="detail_id"></param>
        public string Split(string deliver_id, string[] detail_ids)
        {
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connString);
            SerialDao serialDao = new SerialDao("");
            StringBuilder sql = new StringBuilder();
            System.Net.IPAddress[] addlist = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList;
            string detail_id = "(";
            foreach (var item in detail_ids)
            {
                detail_id += item + ",";
            }
            detail_id = detail_id.TrimEnd(',');
            detail_id += ")";
            int i = 0;
            string ip = string.Empty;
            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.AppendFormat(@" SELECT order_id,type,export_id,import_id,freight_set,delivery_name,delivery_mobile,");
                sql.AppendFormat(@" delivery_phone, delivery_zip,delivery_store,delivery_address  from deliver_master ");
                sql.AppendFormat(@" where deliver_id='{0}';", deliver_id);
                List<DeliverMaster> store = _access.getDataTableForObj<DeliverMaster>(sql.ToString());
                DeliverMaster dm = new DeliverMaster();
                if (store.Count > 0)
                {
                    dm = store[0];
                }
                mySqlCmd.CommandText = serialDao.Update(76); //deliver_master
                dm.deliver_id = uint.Parse(mySqlCmd.ExecuteScalar().ToString());
                dm.creator = user_id;
                dm.verifier = user_id;
                dm.created = DateTime.Now;
                dm.modified = DateTime.Now;
                sql.Clear();
                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,");
                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}','{1}','{2}','{3}','{4}',",null,null, null,null, dm.estimated_arrival_period);
                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();
                sql.Clear();
                sql.AppendFormat(@" update deliver_detail set deliver_id='{0}'", dm.deliver_id);
                sql.AppendFormat(@" where deliver_id='{0}' and detail_id in {1};", deliver_id, detail_id);
                mySqlCmd.CommandText = sql.ToString();
                i = mySqlCmd.ExecuteNonQuery();
                sql.Clear();
                if (dm.delivery_store == 42)//到店取貨
                {
                    sql.AppendFormat(@" SELECT order_id FROM split_single_remind WHERE order_id ='{0}'; ", dm.order_id);
                    mySqlCmd.CommandText = sql.ToString();
                    object ob = mySqlCmd.ExecuteScalar();
                    sql.Clear();
                    if (ob == null)
                    {
                        sql.AppendFormat(@" insert into split_single_remind SET order_id='{0}', status=0, set_time='{1}';", dm.order_id, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        mySqlCmd.CommandText = sql.ToString();
                        i = mySqlCmd.ExecuteNonQuery();
                        sql.Clear();
                    }
                }
                DeliverStatus dstatus = new DeliverStatus();
                dstatus.deliver_id = int.Parse(deliver_id);
                dstatus.state = 3;
                dstatus.settime = DateTime.Now;
                dstatus.endtime = DateTime.Now;
                dstatus.freight_type = int.Parse(dm.delivery_store.ToString()) == 42 ? 12 : 11;
                dstatus.Logistics_providers = int.Parse(dm.delivery_store.ToString());
                sql.AppendFormat(@" insert into deliver_status (deliver_id,state,settime,endtime,freight_type,Logistics_providers)");
                sql.AppendFormat(@" values('{0}','{1}','{2}',", dstatus.deliver_id, dstatus.state, dstatus.settime.ToString("yyyy-MM-dd HH:mm:ss"));
                sql.AppendFormat(@" '{0}','{1}','{2}');", dstatus.endtime.ToString("yyyy-MM-dd HH:mm:ss"), dstatus.freight_type, dstatus.Logistics_providers);
                mySqlCmd.CommandText = sql.ToString();
                i = mySqlCmd.ExecuteNonQuery();
                sql.Clear();

                //供應商自出
                if (dm.type == 2)
                {
                    uint sumtotal = 0;
                    sql.Clear();
                    sql.AppendFormat(@"SELECT  os.slave_id, order_id,vendor_id, slave_status,");
                    sql.AppendFormat(@"SUM(od.single_money * od.buy_num) AS subtotal");
                    sql.AppendFormat(@" from order_slave os LEFT JOIN order_detail od on os.slave_id=od.slave_id");
                    sql.AppendFormat(@" where od.detail_id in {0} GROUP BY os.slave_id  limit 1;", detail_id);
                    DataTable dt = _access.getDataTable(sql.ToString());
                    for (int j = 0; j < detail_ids.Length; j++)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            DataRow dr = dt.Rows[0];
                            uint subtotal = (!string.IsNullOrEmpty(dr["subtotal"].ToString())) ? uint.Parse(dr["subtotal"].ToString()) : 0;
                            sumtotal += subtotal;
                        }
                    }
                    sql.Clear();
                    sql.AppendFormat(@" update order_slave set slave_product_subtotal=slave_product_subtotal-{0},", sumtotal);
                    sql.AppendFormat(@" slave_amount=slave_amount-{0},slave_updatedate='{1}', ", sumtotal, uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString()));
                    sql.AppendFormat(@" slave_ipfrom='{0}' where slave_id='{1}';", ip, dt.Rows.Count.ToString() != "0" ? dt.Rows[0]["slave_id"].ToString() : "");
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();
                    sql.Clear();
                    OrderSlave os = new OrderSlave();
                    mySqlCmd.CommandText = serialDao.Update(30); //order_slave
                    os.Slave_Id = uint.Parse(mySqlCmd.ExecuteScalar().ToString());
                    os.Slave_Product_Subtotal = sumtotal;
                    os.Slave_Amount = sumtotal;
                    if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["order_id"].ToString()))
                    {
                        os.Order_Id = uint.Parse(dt.Rows[0]["order_id"].ToString());
                    }
                    if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["vendor_id"].ToString()))
                    {
                        os.Vendor_Id = uint.Parse(dt.Rows[0]["vendor_id"].ToString());
                    }
                    if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["slave_status"].ToString()))
                    {
                        os.Slave_Status = uint.Parse(dt.Rows[0]["slave_status"].ToString());
                    }
                    os.Slave_Ipfrom = ip;
                    os.Slave_Updatedate = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString());
                    sql.Clear();
                    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();
                    sql.Clear();
                    sql.AppendFormat(@" update order_detail set slave_id='{0}' where detail_id in {1};", os.Slave_Id, detail_id);
                    mySqlCmd.CommandText = sql.ToString();
                    i = mySqlCmd.ExecuteNonQuery();

                }
                mySqlCmd.Transaction.Commit();
                return dm.deliver_id.ToString();
            }
            catch (Exception ex)
            {

                mySqlCmd.Transaction.Rollback();
                return null;
                throw new Exception("DeliverDetailDao-->Split-->" + ex.Message + sql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }

        }
예제 #2
0
        /// <summary>
        /// 回填物流單號
        /// </summary>
        /// <param name="deliver_id">出貨單號</param>
        /// <param name="delivery_store">物流方式</param>
        /// <param name="delivery_code">物流單號</param>
        /// <param name="delivery_date">出貨日期</param>
        /// <param name="vendor_id">供應商</param>
        public bool DeliveryCode(string deliver_id, string delivery_store, string delivery_code, string delivery_date = null, string vendor_id = "0")
        {
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connString);
            StringBuilder sql = new StringBuilder();
            StringBuilder allsql = new StringBuilder();
            object ob;
            sql.AppendLine(@"SELECT dm.order_id,dm.type,dm.freight_set,dm.delivery_mobile,");
            sql.AppendLine(@"dm.delivery_status,dm.delivery_date,om.user_id,om.order_name,");
            sql.AppendLine(@"om.delivery_mobile,om.delivery_phone,om.delivery_address,");
            sql.AppendLine(@"om.note_order,om.note_admin,om.delivery_name");
            sql.AppendLine(@" from deliver_master dm LEFT JOIN order_master om on dm.order_id=om.order_id ");
            sql.AppendFormat(@" where dm.deliver_id='{0}' ", deliver_id);
            if (vendor_id != "0")
            {
                sql.AppendFormat(@" and dm.export_id='{0}'", vendor_id);
            }
            sql.AppendFormat(" limit 1;");
            allsql.Append(sql.ToString());
            DataTable delivermaster = _access.getDataTable(sql.ToString());
            try
            {
                if (delivermaster.Rows.Count > 0)
                {
                    if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                    {
                        mySqlConn.Open();
                    }
                    mySqlCmd.Connection = mySqlConn;
                    mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                    mySqlCmd.CommandType = System.Data.CommandType.Text;
                    string delivery_status = "3"; //已出貨
                    string detail_status = "4"; //已出貨
                    string user_id = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    delivery_date = (!string.IsNullOrEmpty(delivery_date)) ? delivery_date : DateTime.Now.ToString("yyyy-MM-dd");
                    if (delivery_store == "12" || delivery_store == "13" || delivery_store == "14")
                    {
                        if (delivermaster.Rows[0]["delivery_status"].ToString() == "0")
                        {
                            delivery_status = "7"; //待取貨
                            detail_status = "9"; //待取貨
                        }
                    }
                    //deliver_master表  update  delivery_status
                    sql.Clear();
                    sql.AppendFormat(@" update deliver_master set delivery_status='{0}', delivery_store='{1}',", delivery_status, delivery_store);
                    sql.AppendFormat(@" delivery_code='{0}', delivery_date='{1}',", delivery_code, (!string.IsNullOrEmpty(delivery_date)) ? delivery_date : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    sql.AppendFormat(@" verifier='{0}', modified='{1}'  where deliver_id='{2}';", user_id, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), deliver_id);
                    mySqlCmd.CommandText = sql.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    //更新export_flag
                    if (delivermaster.Rows[0]["delivery_status"].ToString() == "0" && string.IsNullOrEmpty(delivermaster.Rows[0]["delivery_date"].ToString()))
                    {
                        sql.Clear();
                        //出貨單押單時,將deliver_master.export_flag設為1
                        sql.AppendFormat(@" update deliver_master set export_flag=1 where deliver_id='{0}';", deliver_id);
                        mySqlCmd.CommandText = sql.ToString();
                        mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                    }
                    sql.Clear();
                    //deliver_detail表 update deliver_detail
                    sql.AppendFormat(@"update deliver_detail set delivery_status='{0}'", delivery_status);
                    sql.AppendFormat(@" where deliver_id='{0}' and delivery_status in (0, 1, 2, 7);", deliver_id);
                    mySqlCmd.CommandText = sql.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    // update ticket_status
                    sql.Clear();
                    sql.AppendFormat(@"SELECT ticket_id from deliver_master where deliver_id='{0}';", deliver_id);
                    string ticket_id = string.Empty;
                    mySqlCmd.CommandText = sql.ToString();
                    ob = mySqlCmd.ExecuteScalar();
                    if (ob != null)
                    {
                        ticket_id = ob.ToString();
                    }
                    //string ticket_id = mySqlCmd.ExecuteScalar().ToString();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    sql.AppendFormat(@"SELECT count(deliver_id) from deliver_master where ticket_id='{0}' ", ticket_id);
                    sql.AppendFormat(@" and delivery_status not in (3, 5);");//已出貨 取消出貨
                    mySqlCmd.CommandText = sql.ToString();
                    ob = mySqlCmd.ExecuteScalar();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    if (ob.ToString() == "0")
                    {
                        allsql.Append(sql.ToString());
                        sql.Clear();
                        sql.AppendFormat(@" update ticket set ticket_status=1,verifier='{0}', ", user_id);//已出貨
                        sql.AppendFormat(@" modified='{0}' where ticket_id='{1}';", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ticket_id);
                        mySqlCmd.CommandText = sql.ToString();
                        mySqlCmd.ExecuteNonQuery();
                        allsql.Append(sql.ToString());
                    }
                    // update detail_status
                    string ds = delivermaster.Rows[0]["type"].ToString() == "1" ? "(6, 7, 9)" : "(2, 6)";
                    sql.AppendFormat(@" UPDATE order_detail set detail_status='{0}' where detail_id in( SELECT * FROM (", detail_status);
                    sql.AppendFormat(@" SELECT dd.detail_id from deliver_detail dd LEFT JOIN order_detail od on dd.detail_id=od.detail_id");
                    sql.AppendFormat(@" WHERE deliver_id='{0}' and od.detail_status IN {1} ) T );", deliver_id, ds);//6 修正自出被改成調度
                    mySqlCmd.CommandText = sql.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    // update slave_status
                    sql.AppendFormat(@"UPDATE order_slave set slave_status='4' where slave_id in ");//已出貨
                    sql.AppendFormat(@"(SELECT T.slave_id FROM (SELECT os.slave_id from deliver_master dm LEFT JOIN order_master om ");
                    sql.AppendFormat(@"on dm.order_id=om.order_id LEFT JOIN order_slave os on os.order_id=dm.order_id ");
                    sql.AppendFormat(@"LEFT JOIN order_detail od ON os.slave_id=od.slave_id ");
                    sql.AppendFormat(@"where od.detail_status in(2,3,4,6,7,9) and dm.deliver_id='{0}' GROUP BY os.slave_id ", deliver_id);//需出貨
                    sql.AppendFormat(@"HAVING SUM(od.detail_status!=4)=0) T) AND slave_status != 99;");
                    mySqlCmd.CommandText = sql.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    //update order_status
                    sql.AppendFormat(@"UPDATE order_master set order_status='4' where order_id in ");
                    sql.AppendFormat(@" (SELECT T.order_id FROM (SELECT dm.order_id from deliver_master dm LEFT JOIN order_master om ");
                    sql.AppendFormat(@"on dm.order_id=om.order_id LEFT JOIN order_slave os on os.order_id=dm.order_id ");
                    sql.AppendFormat(@"where os.slave_status in(2,4,6) and dm.deliver_id='{0}' GROUP BY dm.order_id", deliver_id);
                    sql.AppendFormat(@" HAVING SUM(os.slave_status!=4)=0) T) and order_status!=99;");
                    mySqlCmd.CommandText = sql.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();

                    DeliverStatus dstatus = new DeliverStatus();
                    dstatus.deliver_id = int.Parse(deliver_id);
                    dstatus.state = 3;
                    dstatus.settime = DateTime.Now;
                    dstatus.endtime = DateTime.Now;
                    dstatus.freight_type = int.Parse(delivery_store) == 42 ? 12 : 11;
                    dstatus.Logistics_providers = int.Parse(delivery_store);
                    sql.AppendFormat(@" insert into deliver_status (deliver_id,state,settime,endtime,freight_type,Logistics_providers)");
                    sql.AppendFormat(@" values('{0}','{1}','{2}',", dstatus.deliver_id, dstatus.state, dstatus.settime.ToString("yyyy-MM-dd HH:mm:ss"));
                    sql.AppendFormat(@" '{0}','{1}','{2}');", dstatus.endtime.ToString("yyyy-MM-dd HH:mm:ss"), dstatus.freight_type, dstatus.Logistics_providers);
                    mySqlCmd.CommandText = sql.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    allsql.Append(sql.ToString());
                    sql.Clear();
                    #region 建立車隊pda資料
                    //建立車隊pda資料
                    //if (delivery_store == "16" || delivery_store == "17")
                    //{
                    //    sql.AppendLine(@" delete from delivery where De004=4;");
                    //    mySqlCmd.CommandText = sql.ToString();
                    //    mySqlCmd.ExecuteNonQuery();
                    //    allsql.Append(sql.ToString());
                    //    sql.Clear();
                    //    sql.AppendFormat(@"SELECT * from delivery where De000='{0}' LIMIT 1;", delivermaster.Rows[0]["order_id"]);
                    //    if (_access.getDataTable(sql.ToString()).Rows.Count == 0)
                    //    {
                    //        Delivery d = new Delivery();
                    //        d.De000 = delivermaster.Rows[0]["order_id"].ToString();//訂單號
                    //        d.De001 = delivermaster.Rows[0]["user_id"].ToString();//客戶代號
                    //        d.De002 = delivermaster.Rows[0]["delivery_address"].ToString();//客戶地址
                    //        d.De003 = 1;//配送順序
                    //        d.De004 = "3";//配送狀態
                    //        d.De005 = (!string.IsNullOrEmpty(delivermaster.Rows[0]["note_order"].ToString())) ? delivermaster.Rows[0]["note_order"].ToString() : delivermaster.Rows[0]["note_admin"].ToString();//配送備註
                    //        d.De006 = delivermaster.Rows[0]["delivery_name"].ToString();//簽收人
                    //        d.De007 = DateTime.Now;//修改時間
                    //        d.De008 = user_id;//新增人員
                    //        d.Cust02 = delivermaster.Rows[0]["delivery_name"].ToString();//客戶名稱
                    //        d.Cust03 = delivermaster.Rows[0]["delivery_mobile"].ToString();//客戶電話一
                    //        d.Cust04 = delivermaster.Rows[0]["delivery_phone"].ToString();//客戶電話二
                    //        d.Cust05 = (!string.IsNullOrEmpty(delivermaster.Rows[0]["note_order"].ToString())) ? delivermaster.Rows[0]["note_order"].ToString() : delivermaster.Rows[0]["note_admin"].ToString();//備註
                    //        sql.AppendFormat(@" insert into delivery (De000,De001,De002,De003,");
                    //        sql.AppendFormat(@"De004,De005,De006,De007,De008,");
                    //        sql.AppendFormat(@"Cust02,Cust03,Cust04,Cust05)");
                    //        sql.AppendFormat(@" values('{0}','{1}','{2}','{3}',", d.De000, d.De001, d.De002, d.De003);
                    //        sql.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}',", d.De004, d.De005, d.De006, d.De007.ToString("yyyy-MM-dd HH:mm:ss"), d.De008);
                    //        sql.AppendFormat(@"'{0}','{1}','{2}','{3}')", d.Cust02, d.Cust03, d.Cust04, d.Cust05);
                    //        mySqlCmd.CommandText = sql.ToString();
                    //        mySqlCmd.ExecuteNonQuery();
                    //        allsql.Append(sql.ToString());
                    //    }
                    //    sql.Clear();
                    //    sql.AppendLine(@" delete from pickup  where Pick003=4;");
                    //    mySqlCmd.CommandText = sql.ToString();
                    //    mySqlCmd.ExecuteNonQuery();
                    //    allsql.Append(sql.ToString());
                    //    sql.Clear();
                    //    sql.AppendFormat(@"SELECT * from pickup where Pick001='{0}' LIMIT 1;", "D" + deliver_id.PadLeft(8, '0'));
                    //    if (_access.getDataTable(sql.ToString()).Rows.Count == 0)
                    //    {
                    //        Pickup p = new Pickup();
                    //        p.De000 = delivermaster.Rows[0]["order_id"].ToString();//訂單號;
                    //        p.Pick001 = "D" + delivermaster.Rows[0]["deliver_id"].ToString().PadLeft(8, '0');//出貨單號
                    //        p.Pick002 = 1;//箱數
                    //        p.Pick003 = "3";//狀態
                    //        p.Pick004 = (delivermaster.Rows[0]["freight_set"].ToString() == "1" || delivermaster.Rows[0]["freight_set"].ToString() == "1") ? "1" : "2";//溫層
                    //        p.Pick005 = DateTime.Now;//修改時間
                    //        p.Pick006 = user_id;//修改人員
                    //        sql.Clear();
                    //        sql.AppendFormat(@" insert into pickup (De000,Pick001,Pick002,Pick003,");
                    //        sql.AppendFormat(@"Pick004,Pick005,Pick006) values(");
                    //        sql.AppendFormat(@"'{0}','{1}','{2}','{3}',", p.De000, p.Pick001, p.Pick002, p.Pick003);
                    //        sql.AppendFormat(@"'{0}','{1}','{2}')", p.Pick004, p.Pick005.ToString("yyyy-MM-dd HH:mm:ss"), p.Pick006);
                    //        mySqlCmd.CommandText = sql.ToString();
                    //        mySqlCmd.ExecuteNonQuery();
                    //        allsql.Append(sql.ToString());
                    //    }

                    //}
                    #endregion
                    mySqlCmd.Transaction.Commit();
                    #region
                    if (string.IsNullOrEmpty(delivery_date) && delivermaster.Rows[0]["type"].ToString() == "1" && delivermaster.Rows[0]["delivery_status"].ToString() == "0" && !string.IsNullOrEmpty(delivermaster.Rows[0]["delivery_mobile"].ToString()))
                    {
                        if (delivery_store != "11" && delivery_store != "40" && delivery_store != "99")//7-11取貨(Yahoo) 公司自送 其它
                        {
                            sql.Clear();
                            sql.AppendFormat(@" SELECT c.* FROM order_master om INNER JOIN channel c ON om.channel = c.channel_id  WHERE 1=1 AND om.order_id ='{0}' limit 1;", delivermaster.Rows[0]["order_id"]);
                            DataTable channel = _access.getDataTable(sql.ToString());
                            if (channel.Rows.Count > 0)
                            {
                                //1.  若此訂單對應之channel.notify_sms=0,則不發送出貨通知簡訊。
                                string sms_to_date = string.Empty;
                                string sms_to_data = string.Empty;
                                if (channel.Rows[0]["notify_sms"].ToString() != "0")
                                {
                                    string now = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Second.ToString();
                                    //TimeSpan ts
                                    if (DateTime.Parse(now) <= DateTime.Parse("13:00"))
                                    {
                                        sms_to_date = DateTime.Now.ToString("yyyy-MM-dd") + " 13:30:00";
                                    }
                                    else if (DateTime.Parse(now) >= DateTime.Parse("13:00") && DateTime.Parse(now) <= DateTime.Parse("16:00"))
                                    {
                                        sms_to_date = DateTime.Now.ToString("yyyy-MM-dd") + " 16:30:00";
                                    }
                                    else
                                    {
                                        sms_to_date = DateTime.Now.ToString("yyyy-MM-dd") + " 18:30:00";
                                    }
                                    sms_to_data = "[吉甲地出貨通知]您好,訂單" + delivermaster.Rows[0]["order_id"].ToString() + "(" + delivermaster.Rows[0]["freight_set"].ToString() + ")已於今日" + DateTime.Now.ToString("MM-dd") + "寄出預計明日配達,若有收件問題可回覆此簡訊,客服人員會與您聯繫處理。";
                                    string smssql = Send(4, delivermaster.Rows[0]["order_id"].ToString(), delivermaster.Rows[0]["delivery_mobile"].ToString(), "出貨通知", sms_to_data, sms_to_date, deliver_id);
                                    mySqlCmd.CommandText = smssql;
                                    mySqlCmd.ExecuteNonQuery();
                                    allsql.Append(smssql);
                                    sql.Clear();
                                }
                            }

                        }
                    }
                    #endregion
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                return false;
                throw new Exception("DeliverDetailDao-->DeliveryCode-->" + ex.Message + sql.ToString(), ex);

            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
        }