示例#1
0
 public List<DeliverMasterQuery> JudgeOrdid(DeliverMaster dm)
 {
     try
     {
         return _ideliver.JudgeOrdid(dm);
     }
     catch (Exception ex)
     {
         throw new Exception("DeliverMasterMgr-->JudgeOrdid-->" + ex.Message, ex);
     }
 }
示例#2
0
 public List<DeliverMasterQuery> DeliverVerifyList(DeliverMaster deliver, out int totalCount)
 {
     try
     {
         return _ideliver.DeliverVerifyList(deliver, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("DeliverMasterMgr-->DeliverVerifyList-->" + ex.Message, ex);
     }
 }
示例#3
0
 public void Add(DeliverMaster dm)
 {
     StringBuilder sbSql = new StringBuilder();
     try
     {
         sbSql.AppendFormat(@"insert into deliver_master(deliver_id,detail_id,delivery_status) values()");
     }
     catch (Exception ex)
     {
         throw new Exception(" DeliverMasterDao-->Add-->" + ex.Message + sbSql.ToString(), ex);
     }
 }
示例#4
0
        public List<DeliverMasterQuery> JudgeOrdid(DeliverMaster dm)
        {
            StringBuilder sbSql = new StringBuilder();
            try
            {
                sbSql.Append(@"SELECT dm.deliver_id,dm.order_id,dm.delivery_status,CONCAT('(',tp2.parameterName,tp1.parameterName,')') as delivery_store_name,dm.delivery_store from deliver_master dm ");
                sbSql.Append(@"LEFT JOIN deliver_detail dd ON dm.deliver_id = dd.deliver_id  ");
                sbSql.Append(@"LEFT JOIN order_detail od ON dd.detail_id=od.detail_id ");
                sbSql.Append(@"LEFT JOIN t_parametersrc tp1 ON dm.delivery_store = tp1.parameterCode AND tp1.parameterType='Deliver_Store' ");
                sbSql.Append(@"LEFT JOIN t_parametersrc tp2 ON od.product_freight_set = tp2.parameterCode AND tp2.parameterType='product_freight' ");
                sbSql.Append(@" where 1=1");


                if (dm.deliver_id != 0)
                {
                    sbSql.AppendFormat(@" AND dm.deliver_id='{0}' ", dm.deliver_id);
                }
                if (dm.order_id != 0)
                {
                    sbSql.AppendFormat(@" AND dm.order_id='{0}' ", dm.order_id);
                }
                sbSql.Append(" limit 1;");
                return _access.getDataTableForObj<DeliverMasterQuery>(sbSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(" DeliverMasterDao-->JudgeOrdid-->" + ex.Message + sbSql.ToString(), ex);
            }

        }
示例#5
0
        public List<DeliverMasterQuery> DeliverVerifyList(DeliverMaster dm, out int totalCount)
        {
            StringBuilder sbSql = new StringBuilder();
            try
            {
                totalCount = 0;
                //sbSql.Append(@"SELECT dm.deliver_id,dm.order_id,pi.item_id,od.product_name,od.buy_num,tp.remark AS 'status',CONCAT('(',tp2.parameterName,tp1.parameterName,')') as delivery_store_name  from deliver_master dm ");
                //sbSql.Append(@"LEFT JOIN deliver_detail dd ON dm.deliver_id = dd.deliver_id ");
                //sbSql.Append(@"LEFT JOIN order_detail od ON dd.detail_id = od.detail_id ");
                //sbSql.Append(@"LEFT JOIN product_item pi ON od.item_id = pi.item_id ");
                //sbSql.Append(@"LEFT JOIN product p ON pi.product_id = p.product_id ");
                //sbSql.Append(@"LEFT JOIN t_parametersrc tp ON od.detail_status = tp.parameterCode AND tp.parameterType='order_status' ");
                //sbSql.Append(@"LEFT JOIN t_parametersrc tp1 ON dm.delivery_store = tp1.parameterCode AND tp1.parameterType='Deliver_Store' ");
                //sbSql.Append(@"LEFT JOIN t_parametersrc tp2 ON od.product_freight_set = tp2.parameterCode AND tp2.parameterType='product_freight' ");
                //od.detail_status,dd.detail_id, od.parent_name,  od.product_spec_name,od.product_freight_set,od.item_vendor_id,od.product_mode,od.combined_mode,od.parent_id,od.item_mode,od.pack_id,od.parent_num,p.product_mode,
                // 轉型錯誤  dd.delivery_status,
                sbSql.Append(@"select  pi.item_id, od.product_name, od.buy_num,dd.deliver_id, 
dm.order_id,tp.remark AS 'status',CONCAT('(',tp2.parameterName,tp1.parameterName,')') as delivery_store_name 
from deliver_detail dd
left join order_detail od on dd.detail_id=od.detail_id
left join product_item  pi on od.item_id=pi.item_id
left join product p on p.product_id=pi.product_id
left join deliver_master dm ON dm.deliver_id = dd.deliver_id 
LEFT JOIN t_parametersrc tp ON od.detail_status = tp.parameterCode AND tp.parameterType='order_status' 
LEFT JOIN t_parametersrc tp1 ON dm.delivery_store = tp1.parameterCode AND tp1.parameterType='Deliver_Store' 
LEFT JOIN t_parametersrc tp2 ON od.product_freight_set = tp2.parameterCode AND tp2.parameterType='product_freight'
");
                sbSql.Append(@" where 1=1 ");
                if (dm.deliver_id != 0 && dm.order_id != 0)
                {
                    //sbSql.AppendFormat(@" AND dm.deliver_id='{0}' AND dm.order_id='{1}' ", dm.deliver_id, dm.order_id); 
                    sbSql.AppendFormat(@" AND dd.deliver_id='{0}' ", dm.deliver_id);
                }
                sbSql.Append(@" order by od.item_vendor_id asc ,od.item_id asc ");
                //if (dm.IsPage)
                //{
                //    System.Data.DataTable _dt = _access.getDataTable(sbSql.ToString());
                //    if ( _dt.Rows.Count > 0)
                //    {
                //        totalCount = _dt.Rows.Count;
                //    }
                //    sbSql.AppendFormat(" limit {0},{1}", dm.Start, dm.Limit);
                //}
                return _access.getDataTableForObj<DeliverMasterQuery>(sbSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(" DeliverMasterDao-->DeliverVerifyList-->" + ex.Message + sbSql.ToString(), ex);
            }
        }
示例#6
0
 public int DeliverMasterEdit(DeliverMaster dm, int type)
 {
     try
     {
         return _IDeliverDetailDao.DeliverMasterEdit(dm, type);
     }
     catch (Exception ex)
     {
         throw new Exception("DeliverDetailMgr-->DeliverMasterEdit-->" + ex.Message, ex);
     }
 }
示例#7
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();
                }
            }

        }
示例#8
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();
                }
            }
        }
示例#9
0
 /// <summary>
 /// 編輯
 /// </summary>
 /// <param name="dm"></param>
 /// <param name="type">區分變更到貨時間還是變更收件人資料</param>
 /// <returns></returns>
 public int DeliverMasterEdit(DeliverMaster dm, int type)
 {
     StringBuilder sql = new StringBuilder();
     int user_id = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
     try
     {
         sql.AppendFormat(@" update deliver_master set ");
         if (type == 1)
         {
             if (dm.estimated_delivery_date != DateTime.MinValue)
             {
                 sql.AppendFormat(@" estimated_delivery_date='{0}',", dm.estimated_delivery_date.ToString("yyyy-MM-dd"));
             }
             else
             {
                 sql.AppendFormat(@" estimated_delivery_date=null,");
             }
             if (dm.estimated_arrival_date != DateTime.MinValue)
             {
                 sql.AppendFormat(@" estimated_arrival_date='{0}',", dm.estimated_arrival_date.ToString("yyyy-MM-dd"));
             }
             else
             {
                 sql.AppendFormat(@" estimated_arrival_date=null,");
             }
             sql.AppendFormat(@" estimated_arrival_period='{0}' ", dm.estimated_arrival_period);
         }
         if (type == 2)
         {
             sql.AppendFormat(@" delivery_name='{0}',delivery_mobile='{1}',delivery_phone='{2}',", dm.delivery_name, dm.delivery_mobile, dm.delivery_phone);
             sql.AppendFormat(@" delivery_zip='{0}',delivery_address='{1}'", dm.delivery_zip, dm.delivery_address);
         }
         sql.AppendFormat(@" ,modified='{0}',verifier='{1}' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), user_id);
         sql.AppendFormat(@" where deliver_id='{0}';", dm.deliver_id);
         return _access.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception(" DeliverMasterDao-->DeliverMasterEdit-->" + ex.Message + sql.ToString(), ex);
     }
 }
示例#10
0
        /// <summary>
        /// 修改物流單號 出貨日期 出貨信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase DeliverDetailEdit()
        {
            string json = string.Empty;
            try
            {
                _DeliverDetailMgr = new DeliverDetailMgr(mySqlConnectionString);
                string deliver_id = Request.Params["deliver_id"];
                string delivery_store = string.Empty;
                string delivery_code = string.Empty;
                string delivery_date = string.Empty;
                string sms_date = string.Empty;
                bool success = false;
                if (!string.IsNullOrEmpty(Request.Params["delivery_store"]) && !string.IsNullOrEmpty(Request.Params["delivery_code"]))
                {
                    delivery_store = Request.Params["delivery_store"];
                    delivery_code = Request.Params["delivery_code"];
                    delivery_date = Request.Params["delivery_date"];
                    success = _DeliverDetailMgr.DeliveryCode(deliver_id, delivery_store, delivery_code, delivery_date, "0");
                    if (success)
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
                else if (!string.IsNullOrEmpty(Request.Params["sms_date"]))
                {
                    Sms sms = new Sms();
                    sms.memo = deliver_id;
                    string smsid = _DeliverDetailMgr.GetSmsId(sms);
                    if (!string.IsNullOrEmpty(smsid))
                    {
                        int i = _DeliverDetailMgr.UpSmsTime(deliver_id, sms_date, smsid);
                        if (i > 0)
                        {
                            json = "{success:true}";
                        }
                        else
                        {
                            json = "{success:false}";
                        }
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
                else
                {
                    DeliverMaster dm = new DeliverMaster();
                    int type = int.Parse(Request.Params["type"]);
                    dm.deliver_id = uint.Parse(deliver_id);
                    if (type == 1)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["estimated_arrival_date"]))
                        {
                            dm.estimated_arrival_date = DateTime.Parse(Request.Params["estimated_arrival_date"]);
                        }
                        if (!string.IsNullOrEmpty(Request.Params["estimated_delivery_date"]))
                        {
                            dm.estimated_delivery_date = DateTime.Parse(Request.Params["estimated_arrival_date"]);
                        }
                        dm.estimated_arrival_period = int.Parse(Request.Params["estimated_arrival_period"]);
                        //dm.estimated_delivery_date = DateTime.Parse(Request.Params["estimated_delivery_date"]);

                    }
                    if (type == 2)
                    {
                        dm.delivery_name = Request.Params["delivery_name"];
                        dm.delivery_mobile = Request.Params["delivery_mobile"];
                        dm.delivery_phone = Request.Params["delivery_phone"];
                        dm.delivery_zip = uint.Parse(Request.Params["delivery_zip"]);
                        dm.delivery_address = Request.Params["delivery_address"];
                    }
                    int j = _DeliverDetailMgr.DeliverMasterEdit(dm, type);
                    if (j == 1)
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }
示例#11
0
 /// <summary>
 /// 驗證訂單編號和出貨單號的對應
 /// </summary>
 /// <returns></returns>
 public HttpResponseBase JudgeOrdid()
 {
     string json = String.Empty;
     DeliverMaster dm = new DeliverMaster();
     List<DeliverMasterQuery> list = new List<DeliverMasterQuery>();
     _DeliverMsterMgr = new DeliverMasterMgr(mySqlConnectionString);
     int msg = 0;
     try
     {
         string deliver_id = Request.Params["deliver_id"];
         string D = deliver_id.Substring(0, 1);
         if (D == "D")
         {
             deliver_id = deliver_id.Substring(1, deliver_id.Length - 1);
             uint deliver; int ord;
             if (uint.TryParse(deliver_id, out deliver))
             {
                 dm.deliver_id = uint.Parse(deliver_id);
             }
             if (int.TryParse(Request.Params["order_id"], out ord))
             {
                 dm.order_id = int.Parse(Request.Params["order_id"]);
             }
             if (dm.deliver_id != 0 && dm.order_id != 0)
             {
                 list = _DeliverMsterMgr.JudgeOrdid(dm);
             }
             if (list.Count > 0)
             {
                 foreach (var item in list)
                 {
                     if (item.delivery_status >= 3)
                     {
                         msg = 2;
                     }
                 }
                 json = "{success:true,msg:" + msg + ",data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回json數據  
             }
             else
             {
                 dm.deliver_id = 0;
                 list = _DeliverMsterMgr.JudgeOrdid(dm);
                 if (list.Count > 0)
                 {
                     msg = 5;
                     json = "{success:true,msg:" + msg + ",data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回json數據  
                 }
                 else
                 {
                     json = "{success:true,msg:1}";
                 }
             }
         }
         else
         {
             json = "{success:true,msg:3}";
         }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false,msg:0}";
     }
     this.Response.Clear();
     this.Response.Write(json.ToString());
     this.Response.End();
     return this.Response;
 }
示例#12
0
 /// <summary>
 /// 出貨確認列表
 /// </summary>
 /// <returns></returns>
 public HttpResponseBase DeliverVerifyList()
 {
     DeliverMaster dm = new DeliverMaster();
     _DeliverMsterMgr = new DeliverMasterMgr(mySqlConnectionString);
     List<DeliverMasterQuery> stores = new List<DeliverMasterQuery>();
     string json = string.Empty;
     try
     {
         dm.deliver_id = uint.Parse(Request.Params["deliver_id"]);
         dm.order_id = int.Parse(Request.Params["order_id"]);
         int totalCount = 0;
         stores = _DeliverMsterMgr.DeliverVerifyList(dm, out totalCount);
         json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:true,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }