Exemple #1
0
 public bool ThingsMethod(string[] rows, OrderDeliver order, OrderSlaveMaster master, string Descriptions) 
 {
     try
     {
         return _orderDao.ThingsMethod(rows, order, master, Descriptions);
     }
     catch (Exception ex)
     {
         throw new Exception("OrderMgr-->ThingsMethod-->" + ex.Message, ex);
     }
 }
        /// <summary>
        /// 調度出貨:確認出貨
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase DispatchConfirmShipment()
        {
            string jsonStr = String.Empty;
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            BLL.gigade.Model.OrderSlaveMaster master = new OrderSlaveMaster();
            string rowIDs = "";//出貨單號
            string sendProTime = "";//出貨時間
            string delivery_note = "";//出貨單備註
            string DeliverStores = "";//物流單號
            string delivery_Code = "";//物流業者
            string IP = "";
            string Description = "";
            #region 條件
            if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
            {
                rowIDs = Request.Params["rowIDs"];
            }
            if (!string.IsNullOrEmpty(Request.Params["sendProTime"]))
            {
                sendProTime = Request.Params["sendProTime"];
                master.deliver_time = uint.Parse(CommonFunction.GetPHPTime(sendProTime).ToString());
            }
            if (!string.IsNullOrEmpty(Request.Params["delivery_note"]))
            {
                delivery_note = Request.Params["delivery_note"];
            }
            if (!string.IsNullOrEmpty(Request.Params["DeliverStores"]))
            {
                DeliverStores = Request.Params["DeliverStores"];
            }
            if (!string.IsNullOrEmpty(Request.Params["delivery_Code"]))
            {
                delivery_Code = Request.Params["delivery_Code"];
            }
            if (!string.IsNullOrEmpty(Request.Params["normal_Subtotal"]))
            {
                master.normal_subtotal = uint.Parse(Request.Params["normal_Subtotal"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["hypothermia_Subtotal"]))
            {
                master.hypothermia_subtotal = uint.Parse(Request.Params["hypothermia_Subtotal"]);
            }
            master.creator = vendor.vendor_id;
            //if (!string.IsNullOrEmpty(Request.Params["freight_Normal"]))
            //{
            //    master.fre = Request.Params["freight_Normal"];
            //}
            //if (!string.IsNullOrEmpty(Request.Params["hypothermia_Subtotal"]))
            //{
            //    hypothermia_Subtotal = Request.Params["hypothermia_Subtotal"];
            //}
            //if (!string.IsNullOrEmpty(Request.Params["freight_Low"]))
            //{
            //    freight_Low = Request.Params["freight_Low"];
            //}
            if (!string.IsNullOrEmpty(Request.Params["order_Freight_Normal"]))
            {
                master.order_freight_normal = uint.Parse(Request.Params["order_Freight_Normal"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["Order_Freight_Low"]))
            {
                master.order_freight_low = uint.Parse(Request.Params["Order_Freight_Low"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["code"]))
            {
                master.code_num = Request.Params["code"];
            }

            System.Net.IPAddress[] addlist = Dns.GetHostByName(Dns.GetHostName()).AddressList;
            if (addlist.Length > 0)
            {
                IP = addlist[0].ToString();
            }
            rowIDs = rowIDs.TrimEnd(',');//去掉最後一個分割符號
            string[] Sid_Row = rowIDs.Split(',');//拆分
            #endregion
            OrderDeliver order = new OrderDeliver();
            order.deliver_code = delivery_Code;
            order.deliver_store = uint.Parse(DeliverStores);
            order.deliver_note = delivery_note;
            order.deliver_ipfrom = IP;
            try
            {
                order.deliver_time = uint.Parse(CommonFunction.GetPHPTime(sendProTime).ToString());
                Description = "Writer : vendor(" + vendor.vendor_id + ") " + vendor.vendor_name_simple + "批次出貨";
                _OrderMgr = new OrderMgr(mySqlConnectionString);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                _OrderMgr.ThingsMethod(Sid_Row, order, master, Description);//出貨成功!
                // jsonStr = "{success:true}";//返回json數據
                jsonStr = "{success:true,msg:\"" + 1 + "\"}";
            }
            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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
        /// <summary>
        /// 供應商自行出貨確認
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SelfConfirmShipment()
        {
            string jsonStr = String.Empty;
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            BLL.gigade.Model.OrderSlaveMaster master = new OrderSlaveMaster();
            OrderDeliverQuery query = new OrderDeliverQuery();
            uint Slave_Id = 0;//要出貨的訂單;
            string Select_Did = "";//選中要出貨的出貨單號
            DateTime sendProTime = DateTime.MinValue;//出貨時間
            string delivery_note = "";//出貨單備註
            uint DeliverStores = 0;//物流單號
            string delivery_Code = "";//物流業者
            string IP = "";
            string Description = "";
            #region 獲取條件
            if (!string.IsNullOrEmpty(Request.Params["Slave_Id"]))
            {
                Slave_Id = uint.Parse(Request.Params["Slave_Id"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["Select_Did"]))
            {
                Select_Did = Request.Params["Select_Did"];
            }
            if (!string.IsNullOrEmpty(Request.Params["sendProTime"]))
            {
                sendProTime = DateTime.Parse(Request.Params["sendProTime"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["delivery_note"]))
            {
                delivery_note = Request.Params["delivery_note"];
            }
            if (!string.IsNullOrEmpty(Request.Params["DeliverStores"]))
            {
                DeliverStores = uint.Parse(Request.Params["DeliverStores"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["delivery_Code"]))
            {
                delivery_Code = Request.Params["delivery_Code"];
            }
            #endregion
            string did = Select_Did.TrimEnd(',');//去掉最後一個分割符號
            string[] Sid_Row = did.Split(',');//拆分
            List<OrderDetailQuery> store = new List<OrderDetailQuery>();
            OrderDetailQuery querys = new OrderDetailQuery();
            querys.Slave_Id = Slave_Id;
            querys.Vendor_Id = vendor.vendor_id;
            _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
            store = _OrderDetailMgr.DeliveryInformation(querys, null);//查询出供應商出貨單Vendor delivery
            int reslut = 0;
            if (Sid_Row.Length != store.Count)
            {
                #region 轉換數據
                DataTable All_Did = new DataTable();
                All_Did.Columns.Add("detail_id", typeof(String));
                All_Did.Columns.Add("product_name", typeof(String));
                All_Did.Columns.Add("product_freight_set", typeof(String));
                All_Did.Columns.Add("product_spec_name", typeof(String));
                All_Did.Columns.Add("single_money", typeof(String));
                All_Did.Columns.Add("parent_name", typeof(String));
                All_Did.Columns.Add("parent_num", typeof(String));
                All_Did.Columns.Add("combined_mode", typeof(String));
                All_Did.Columns.Add("item_mode", typeof(String));
                All_Did.Columns.Add("buy_num", typeof(String));
                foreach (var item in store)
                {
                    DataRow dr = All_Did.NewRow();
                    dr[0] = item.Detail_Id;
                    dr[1] = item.Product_Name;
                    dr[2] = item.Product_Freight_Set;
                    dr[3] = item.Product_Spec_Name;
                    dr[4] = item.Single_Money;
                    dr[5] = item.parent_name;
                    dr[6] = item.parent_num;
                    dr[7] = item.Combined_Mode;
                    dr[8] = item.item_mode;
                    dr[9] = item.Buy_Num;
                    All_Did.Rows.Add(dr);
                }
                #endregion
                //
                //調用宋東亞
                _OrderDeliverMgr = new OrderDeliverMgr(mySqlConnectionString);
                _OrderDeliverMgr.DismantleSlave(int.Parse(querys.Slave_Id.ToString()), Select_Did, All_Did);
            }

            master.creator = vendor.vendor_id;
            System.Net.IPAddress[] addlist = Dns.GetHostByName(Dns.GetHostName()).AddressList;
            if (addlist.Length > 0)
            {
                IP = addlist[0].ToString();
            }

            try
            {
                OrderDeliver deliver = new OrderDeliver();
                deliver.slave_id = Slave_Id;
                deliver.deliver_store = DeliverStores;
                deliver.deliver_code = delivery_Code;
                deliver.deliver_note = delivery_note;
                deliver.deliver_time = uint.Parse(CommonFunction.GetPHPTime(sendProTime.ToString("yyyy-MM-dd")).ToString());
                deliver.deliver_ipfrom = IP;
                DataTable _dtSms = new DataTable();
                _dtSms.Columns.Add("sms_id", typeof(String));
                DataRow row = _dtSms.NewRow();//需發簡訊通知的item
                row[0] = 113552;
                _dtSms.Rows.Add(row);
                row = _dtSms.NewRow();
                row[0] = 113550;
                _dtSms.Rows.Add(row);
                Description = "Writer : vendor(" + vendor.vendor_id + ") " + vendor.vendor_name_simple;
                _OrderMgr = new OrderMgr(mySqlConnectionString);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                _OrderMgr.SelfThingsMethod(_dtSms, deliver, Description);//出貨成功!

                jsonStr = "{success:true}";//返回json數據
                //   jsonStr = "{success:true,msg:\"" + 1 + "\"}";
            }
            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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Exemple #4
0
        public static string IPAddress = "";//獲取本機的IP地址
        #region 調度商品出貨


        /// <summary>
        /// 調度商品出貨
        /// </summary>
        /// <param name="rows">要出的商品</param>
        /// <param name="order">商品詳細信息</param>
        /// <param name="master"></param>
        /// <param name="Descriptions">描述</param>
        /// <returns></returns>
        public bool ThingsMethod(string[] rows, OrderDeliver order, OrderSlaveMaster master, string Descriptions)
        {
            Description = Descriptions;
            System.Net.IPAddress[] addlist = Dns.GetHostByName(Dns.GetHostName()).AddressList;
            if (addlist.Length > 0)
            {
                IPAddress = addlist[0].ToString();
            }
            StringBuilder sb = new StringBuilder();
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            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;
                SerialDao serial = new SerialDao(connStr);
                mySqlCmd.CommandText = serial.Update(64);// 廠商出貨單總表流水號
                int Master_Slave_Id = int.Parse(mySqlCmd.ExecuteScalar().ToString());//--用這個值新增至出貨單詳情表(order_slave_detail),出貨單主表(order_slave_master)
                foreach (var item in rows)//循環讀取數據
                {
                    sb.AppendFormat(@"select order_id from order_slave  where slave_id='{0}';", item);
                    mySqlCmd.CommandText = sb.ToString();
                    string Order_Id = mySqlCmd.ExecuteScalar().ToString();//--訂單編號,後面會用來修改付款單狀態和查詢訂單流水號詳情
                    sb.Clear();

                    mySqlCmd.CommandText = serial.Update(41);// 廠商出貨單總表流水號
                    int Deliver_Id = int.Parse(mySqlCmd.ExecuteScalar().ToString());//用來新增信息到物流單

                    sb.Append(@"insert into order_deliver (deliver_id,slave_id,deliver_status,deliver_store,deliver_code,deliver_time,");///*新增物流單*/
                    sb.Append("deliver_note,deliver_createdate,deliver_updatedate,deliver_ipfrom )value(");
                    sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}',", Deliver_Id, item, 1, order.deliver_store, order.deliver_code);
                    sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}');", order.deliver_time, order.deliver_note, CommonFunction.GetPHPTime(DateTime.Now.ToString()), 0, order.deliver_ipfrom);
                    mySqlCmd.CommandText = sb.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    sb.Clear();
                    int[] arrays = { 2, 3 };//通過這個數組查詢訂單詳情

                    #region vendor.gigade100.com/order/all_order_deliver.php第357行
                    //vendor.gigade100.com/order/all_order_deliver.php第357行
                    sb.Append(update_detail_for_product_mode(item, arrays, order.deliver_time));//執行事務-參考自includes/order/order.php第1672行方法
                    mySqlCmd.CommandText = sb.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    sb.Clear();
                    //vendor.gigade100.com/order/all_order_deliver.php第360行
                    sb.Append(order_slave_status_record(item, 6, Description));
                    mySqlCmd.CommandText = sb.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    sb.Clear();
                    #endregion
                    // vendor.gigade100.com/order/all_order_deliver.php第361行
                    string Modify_Master_Order_Status = check_vendor_deliver_order_master_status(Order_Id);
                    if (Modify_Master_Order_Status == "false")//參考自(vendor.gigade100.com/order/all_order_deliver.php第363行方法)
                    {
                        mySqlCmd.Transaction.Rollback();
                    }
                    //vendor.gigade100.com/order/all_order_deliver.php第367
                    sb.Append(modify_order_master_status(Order_Id, Modify_Master_Order_Status));
                    mySqlCmd.CommandText = sb.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    sb.Clear();
           
                    #region vendor.gigade100.com/order/all_order_deliver.php第368行方法*/
                    //vendor.gigade100.com/order/all_order_deliver.php第368行方法*/
                    sb.Append(order_master_status_record(Order_Id, Modify_Master_Order_Status, Description));
                    mySqlCmd.CommandText = sb.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    sb.Clear();
                    #endregion


                    //寫入批次出貨單細項
                    /*vendor.gigade100.com/order/all_order_deliver.php 第370行*/
                    sb.AppendFormat(@"INSERT INTO order_slave_detail  (slave_master_id, slave_id) VALUES ('{0}','{1}');", Master_Slave_Id, item);
                    mySqlCmd.CommandText = sb.ToString();
                    mySqlCmd.ExecuteNonQuery();
                    sb.Clear();

                }
                //批次出貨單
                /*vendor.gigade100.com/order/all_order_deliver.php 第384行*/
                sb.AppendFormat("select count(*)  from order_slave_master where 1=1 and creator='{0}' and code_num='{1}';", master.creator, master.code_num);//供应商编号,批次编号
                mySqlCmd.CommandText = sb.ToString();
                int Total_Search = int.Parse(mySqlCmd.ExecuteScalar().ToString());
                sb.Clear();
                Total_Search += 1;
                //vendor.gigade100.com/order/all_order_deliver.php 第412行行方法*/
                sb.Append(@"insert into order_slave_master(slave_master_id,code_num,paper,order_freight_normal,order_freight_low,");
                sb.Append("normal_subtotal,hypothermia_subtotal,deliver_store,deliver_code,deliver_time,deliver_note,createdate,creator) value( ");
                sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}',", Master_Slave_Id, master.code_num, Total_Search, master.order_freight_normal, master.order_freight_low);
                sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}',", master.normal_subtotal, master.hypothermia_subtotal, order.deliver_store, order.deliver_code, master.deliver_time);
                sb.AppendFormat("'{0}','{1}','{2}');", order.deliver_note, CommonFunction.GetPHPTime(DateTime.Now.ToString()), master.creator);
                mySqlCmd.CommandText = sb.ToString();
                mySqlCmd.ExecuteNonQuery();
                sb.Clear();

                mySqlCmd.Transaction.Commit();
                // mySqlCmd.Transaction.Rollback();//---功能完成,用来测试
                return true;
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("OrderDao.ThingsMethod -->" + ex.Message + sb.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
        }