Пример #1
0
        public static IOrderImport InitOrderImport(int ChannelId)
        {

            IOrderImport orderImport = null;
            ChannelMgr channelMgr = new ChannelMgr(GetMySqlConnStr());
            Channel channel=channelMgr.QueryC(" and channel_id='" + ChannelId + "'").FirstOrDefault();
            if (channel != null)
            {
                switch (channel.model_in)
                {
                    case "1":
                        orderImport = new OrderImportZero();
                        break;
                    case "2":
                        orderImport = new OrderImportGigade();
                        break;
                    case "3":
                        orderImport = new OrderImportPayEasy();  //當類型類PayEasy訂單的時候實例化該類型
                        break;
                }
                if (orderImport != null)
                {
                    orderImport.MySqlConnStr = GetMySqlConnStr();
                    orderImport.CurChannel = channel;
                }
            }
            return orderImport;
        }
Пример #2
0
        /// <summary>
        /// 將文件內容存儲到數據庫
        /// </summary>
        /// <param name="all"></param>
        /// <param name="pdfFile"></param>
        /// <param name="importType"></param>
        /// <param name="chkRecord"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public int Import2DB(List<OrdersImport> all, string pdfFile, string importType, string chkRecord, int siteId, ref int totalCount)
        {
            orderImportMgr = new OrderImportMgr(MySqlConnStr, CurChannel.channel_id);
            int successCount = 0;
            try
            {
                List<OrdersImport> chks = orderImportMgr.SplitChkData(chkRecord).FindAll(m => m.chlitpdno != "0");//移除廠商商品編號為0的
                if (chks != null && all != null && all.Count > 0)
                {
                    #region 篩選出選中數據資訊

                    //所有選中商品
                    var result = from h in chks
                                 join o in all on new { h.dmtshxuid, h.chlitpdno } equals new { o.dmtshxuid, o.chlitpdno } into cs
                                 from c in cs.DefaultIfEmpty()
                                 select c;
                    #endregion

                    //所有訂單編號
                    List<string> master = chks.GroupBy(m => m.dmtshxuid).Select(m => m.Key).ToList();
                    totalCount = master == null ? 0 : master.Count;

                    //外站物流業者
                    channelShippingMgr = new ChannelShippingMgr(MySqlConnStr);
                    List<ChannelShipping> shippings = channelShippingMgr.QueryByChannelId(new ChannelShipping { channel_id = CurChannel.channel_id });

                    foreach (var om in master)
                    {
                        //單個訂單下所有商品
                        var product = (from p in result
                                       where p.dmtshxuid == om
                                       select p).ToList();

                        all.FindAll(m => m.dmtshxuid == om && product.Exists(n => n.chlitpdno == m.chlitpdno)).ForEach(m => m.IsSel = true);

                        #region 訂單物流業者

                        ChannelShipping cShipping = null;
                        if (shippings != null)
                        {
                            //查詢該訂單物流業者 取貨方式
                            cShipping = shippings.Where(m => m.shipco.Trim().ToLower() == product.FirstOrDefault().shipco.Trim().ToLower()).FirstOrDefault();
                        }
                        if (shippings == null || cShipping == null)
                        {
                            all.FindAll(m => m.dmtshxuid == om && m.IsSel).ForEach(m => m.Msg = Resource.CoreMessage.GetResource("DELIVERY_MAP_NOT_EXISTS"));
                            continue;
                        }
                        #endregion

                        #region 生成OrderSlave

                        List<OrderSlave> slaves = orderImportMgr.GetSlave(product, all);
                        //訂單內商品有問題(商品對照不存在,商品不存在,商品庫存不足),跳過處理下筆訂單
                        if (slaves == null || slaves.Count == 0)
                        {
                            continue;
                        }
                        #endregion

                        #region OrderMaster

                        OrderMaster newMaster = new OrderMaster();

                        #region 其他信息

                        newMaster.Order_Status = 2;
                        //newMaster.Order_Id = uint.Parse(orderImportMgr.NextOrderId());
                        channelMgr = new ChannelMgr(MySqlConnStr);
                        newMaster.User_Id = Convert.ToUInt32(channelMgr.GetUserIdByChannelId(CurChannel.channel_id));

                        //備註
                        if (!string.IsNullOrEmpty(product.FirstOrDefault().xrem))
                        {
                            newMaster.Note_Order = "購買備註:" + product.FirstOrDefault().xrem;
                        }
                        if (!string.IsNullOrEmpty(product.FirstOrDefault().shipxrem))
                        {
                            newMaster.Note_Order = string.IsNullOrEmpty(newMaster.Note_Order) ? "配送備註:" + product.FirstOrDefault().shipxrem : newMaster.Note_Order + ",配送備註:" + product.FirstOrDefault().shipxrem;
                        }
                        string name = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_username;
                        newMaster.Note_Admin = name + " 於" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "建立";
                        if (!string.IsNullOrEmpty(product.FirstOrDefault().orddat))
                        {
                            newMaster.Order_Createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(product.FirstOrDefault().orddat));
                        }
                        else
                        {
                            newMaster.Order_Createdate = Convert.ToUInt32(CommonFunction.GetPHPTime());
                        }
                        newMaster.Order_Date_Pay = Convert.ToUInt32(CommonFunction.GetPHPTime());
                        newMaster.Import_Time = DateTime.Now;
                        newMaster.Channel = Convert.ToUInt32(CurChannel.channel_id);
                        newMaster.Channel_Order_Id = product.FirstOrDefault().dmtshxuid;
                        if (!string.IsNullOrEmpty(product.FirstOrDefault().agpesadrzip))
                        {
                            newMaster.Order_Zip = Convert.ToUInt32(product.FirstOrDefault().agpesadrzip);
                        }
                        #endregion

                        #region 发票状态

                        if (CurChannel.receipt_to != 2)
                        {
                            newMaster.Invoice_Status = 2;
                        }
                        #endregion

                        #region 物流方式

                        newMaster.Delivery_Store = Convert.ToUInt32(cShipping.shipping_carrior);
                        newMaster.Retrieve_Mode = Convert.ToUInt32(cShipping.retrieve_mode);

                        #endregion

                        #region 運費

                        var freight = product.Where(m => m.dsr.Contains("物流服務費")).FirstOrDefault();
                        if (freight != null && !string.IsNullOrEmpty(freight.sumup))
                        {
                            if (freight.chlitpdno == "6727_13743")//若廠商商品編號為"6727_13743"是低溫運費
                            {
                                newMaster.Order_Freight_Low = uint.Parse(freight.sumup);
                            }
                            else//若廠商商品編號為"6727_13742"是常溫運費
                            {
                                newMaster.Order_Freight_Normal = uint.Parse(freight.sumup);
                            }
                        }
                        #endregion

                        #region 訂單價格

                        product.Where(m => !m.dsr.Contains("物流服務費")).ToList().ForEach(m => newMaster.Order_Product_Subtotal += uint.Parse(string.IsNullOrEmpty(m.sumup) ? "0" : m.sumup));
                        product.ForEach(m => newMaster.Order_Amount += uint.Parse(string.IsNullOrEmpty(m.sumup) ? "0" : m.sumup));
                        #endregion

                        #region 支付方式
                        //若是外站類型為”合作外站”的,匯入訂單時的 payment = 15
                        newMaster.Order_Payment = 15;
                        //switch (product.FirstOrDefault().Payment)
                        //{
                        //    case "信用卡一次":
                        //        newMaster.Order_Payment = 1;
                        //        break;
                        //    case "7-11貨到付款":
                        //        newMaster.Order_Payment = 15;
                        //        break;
                        //    default:
                        //        newMaster.Order_Payment = 1;
                        //        break;
                        //}
                        #endregion

                        #region 訂購人信息

                        newMaster.Order_Name = product.FirstOrDefault().ordpesnm;
                        newMaster.Order_Mobile = product.FirstOrDefault().ordpesnacttel.Replace("'", "");//去掉電話中的單引號
                        if (string.IsNullOrEmpty(newMaster.Order_Mobile))
                        {
                            newMaster.Order_Mobile = product.FirstOrDefault().agpesacttel.Replace("'", "");//去掉電話中的單引號
                        }
                        newMaster.Order_Address = product.FirstOrDefault().agpesadr;//order_address與delivery_address相同
                        #endregion

                        #region 發貨信息

                        newMaster.Delivery_Name = product.FirstOrDefault().agpesnm;
                        newMaster.Delivery_Mobile = product.FirstOrDefault().agpesacttel.Replace("'", "");//去掉電話中的單引號
                        newMaster.Delivery_Phone = product.FirstOrDefault().agpestel1.Replace("'", "");//去掉電話中的單引號
                        if (!string.IsNullOrEmpty(product.FirstOrDefault().agpesadrzip))
                        {
                            newMaster.Delivery_Zip = uint.Parse(product.FirstOrDefault().agpesadrzip);
                        }
                        newMaster.Delivery_Address = product.FirstOrDefault().agpesadr;
                        #endregion

                        #endregion

                        #region ChannelOrder

                        List<ChannelOrder> cOrder = new List<ChannelOrder>();
                        ChannelOrder channelOrder;
                        foreach (var slave in slaves)
                        {
                            foreach (var detail in slave.Details)
                            {
                                detail.Site_Id = siteId;//add xw 2014/02/03
                                //ChannelOrder
                                channelOrder = new ChannelOrder { Channel_Id = CurChannel.channel_id, Order_Id = newMaster.Channel_Order_Id.ToString() };
                                var p = product.Where(m => m.chlitpdno == detail.Channel_Detail_Id).FirstOrDefault();
                                if (p != null)
                                {
                                    //if (importType == "2")
                                    //{
                                    //    //channelOrder.Store_Dispatch_File = pdfFile;
                                    //}
                                    channelOrder.Dispatch_Seq = p.shipno;
                                    channelOrder.Channel_Detail_Id = detail.Channel_Detail_Id;
                                    if (!string.IsNullOrEmpty(p.orddat))
                                    {
                                        channelOrder.Createtime = Convert.ToDateTime(p.orddat);
                                    }
                                    channelOrder.Ordertime = channelOrder.Createtime;
                                    if (!string.IsNullOrEmpty(p.prndldat))
                                    {
                                        channelOrder.Latest_Deliver_Date = Convert.ToDateTime(p.prndldat);
                                    }
                                    cOrder.Add(channelOrder);
                                }
                            }
                        }
                        #endregion

                        #region 寫入數據庫

                        if (orderImportMgr.Save2DB(newMaster, slaves, cOrder, all))
                        {
                            all.FindAll(m => m.dmtshxuid == om && m.IsSel).ForEach(m => m.Msg = Resource.CoreMessage.GetResource("IMPORT_SUCCESS"));
                            successCount++;
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("OrderImportPayEasy-->Import2DB-->" + ex.Message, ex);
            }
            return successCount;
        }
Пример #3
0
 public HttpResponseBase GetChannel()/*賣場列表*/
 {
     _channel = new ChannelMgr(mySqlConnectionString);
     List<Channel> stores = new List<Channel>();
     string json = string.Empty;
     try
     {
         stores = _channel.QueryList();
         //Channel channel = new Channel();
         //channel.channel_name_simple = "全部";
         //stores.Insert(0, channel);
         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;
 }
Пример #4
0
        public string Query()
        {
            ch.Replace4MySQL();
            chMgr = new ChannelMgr(connectString);

            string json = string.Empty;
            string strSel = string.Empty;
            int startPage = Convert.ToInt32(Request.Form["start"] ?? "0");
            int endPage = Convert.ToInt32(Request.Form["limit"] ?? "20");

            try
            {
                if (!string.IsNullOrEmpty(Request.Form["txtSel"]))
                {
                    if (Request.Form["ddlSel"].ToString() == "full")
                    {
                        ch.channel_name_full = Request.Form["txtSel"].Trim();
                        strSel += " and channel_name_full like '%" + ch.channel_name_full + "%'";
                    }
                    else if (Request.Form["ddlSel"].ToString() == "simple")
                    {
                        ch.channel_name_simple = Request.Form["txtSel"].Trim();
                        strSel += " and channel_name_simple like '%" + ch.channel_name_simple + "%'";
                    }
                }

                if (!string.IsNullOrEmpty(Request.Form["cobStatus"]))
                {
                    if (Request.Form["cobStatus"].ToString() != "0")
                    {
                        ch.channel_status = Int32.Parse(Request.Form["cobStatus"].ToString());
                        strSel += " and channel_status = '" + ch.channel_status + "'";
                    }
                }
                
                json = chMgr.DataPager(strSel,startPage,endPage);
            }
            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 = "[]";
            }
            return json;
        }
Пример #5
0
        public HttpResponseBase SaveChannelOther()
        {
            chMgr = new ChannelMgr(connectString);

            string json = string.Empty;
            int num = 0;

            try
            {
                if (!string.IsNullOrEmpty(Request.Form["channel_id"]))
                {
                    ch.channel_id =Int32.Parse(Request.Form["channel_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["deal_method"]))
                {
                    ch.deal_method = Int32.Parse(Request.Form["deal_method"].ToString());

                    if (Request.Form["deal_method"].ToString() == "2")
                    {
                        ch.deal_percent = float.Parse(Request.Form["deal_percent"].ToString());
                        ch.deal_fee = 0;
                    }
                    else if (Request.Form["deal_method"].ToString() == "3")
                    {
                        ch.deal_percent = 0;
                        ch.deal_fee = Int32.Parse(Request.Form["deal_fee"].ToString());
                    }
                    else
                    {
                        ch.deal_percent = 0;
                        ch.deal_fee = 0;
                    }
                }
                else
                {
                    ch.deal_method = 0;
                    ch.deal_percent = 0;
                    ch.deal_fee = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["creditcard_1_percent"]))
                {
                    ch.creditcard_1_percent = float.Parse(Request.Form["creditcard_1_percent"].ToString());
                }
                else
                {
                    ch.creditcard_1_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["creditcard_3_percent"]))
                {
                    ch.creditcard_3_percent = float.Parse(Request.Form["creditcard_3_percent"].ToString());
                }
                else
                {
                    ch.creditcard_3_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["shopping_car_percent"]))
                {
                    ch.shopping_car_percent = float.Parse(Request.Form["shopping_car_percent"].ToString());
                }
                else
                {
                    ch.shopping_car_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["commission_percent"]))
                {
                    ch.commission_percent = float.Parse(Request.Form["commission_percent"].ToString());
                }
                else
                {
                    ch.commission_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["cost_by_percent"]))
                {
                    ch.cost_by_percent = Int32.Parse(Request.Form["cost_by_percent"].ToString());
                }
                else
                {
                    ch.cost_by_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["cost_low_percent"]))
                {
                    ch.cost_low_percent = float.Parse(Request.Form["cost_low_percent"].ToString());
                }
                else
                {
                    ch.cost_low_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["cost_normal_percent"]))
                {
                    ch.cost_normal_percent = float.Parse(Request.Form["cost_normal_percent"].ToString());
                }
                else
                {
                    ch.cost_normal_percent = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["invoice_checkout_day"]))
                {
                    ch.invoice_checkout_day = Int32.Parse(Request.Form["invoice_checkout_day"].ToString());
                }
                else
                {
                    ch.invoice_checkout_day = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["invoice_apply_start"]))
                {
                    ch.invoice_apply_start = Int32.Parse(Request.Form["invoice_apply_start"].ToString());
                }
                else
                {
                    ch.invoice_apply_start = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["invoice_apply_end"]))
                {
                    ch.invoice_apply_end = Int32.Parse(Request.Form["invoice_apply_end"].ToString());
                }
                else
                {
                    ch.invoice_apply_end = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["checkout_note"]))
                {
                    ch.checkout_note = Request.Form["checkout_note"].ToString();
                }
                else
                {
                    ch.checkout_note = "";
                }

                if (!string.IsNullOrEmpty(Request.Form["receipt_to"]))
                {
                    ch.receipt_to = Int32.Parse(Request.Form["receipt_to"].ToString());
                }
                else
                {
                    ch.receipt_to = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_manager"]))
                {
                    ch.channel_manager = Request.Form["channel_manager"].ToString();
                }
                else
                {
                    ch.channel_manager = "";
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_note"]))
                {
                    ch.channel_note = Request.Form["channel_note"].ToString();
                }
                else
                {
                    ch.channel_note = "";
                }

                num = chMgr.SaveOther(ch);

                if (num > 0)
                {
                    json = "{success:true,msg:\"" + Resources.Channel.SUCCESS + "。\",channelId:" + num.ToString() + "}";
                }
                else
                {
                    json = "{success:true,msg:\"" + Resources.Channel.FAILED + "\"}";
                }
            }
            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,msg:\"" + Resources.Channel.FAILED + "\"}";
            }

            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #6
0
        public HttpResponseBase SaveChannel()
        {
            zMgr = new ZipMgr(connectString);
            chMgr = new ChannelMgr(connectString);
            uMgr = new UsersMgr(connectString);

            string json = string.Empty;
            bool result = false;
            string channel_id = Request.Form["channel_id"] ?? string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["channel_status"]))
                {
                    ch.channel_status = Int32.Parse(Request.Form["channel_status"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_type"]))
                {
                    ch.channel_type = Int32.Parse(Request.Form["channel_type"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_name_full"]))
                {
                    ch.channel_name_full = Request.Form["channel_name_full"].ToString();
                    u.user_name = Request.Form["channel_name_full"].ToString();
                    List<Channel> channel = chMgr.QueryC(" and channel_name_full='" + Request.Form["channel_name_full"] + "'");
                    if (channel != null && channel.Count > 0 && channel.Where(m => m.channel_id == int.Parse(string.IsNullOrEmpty(channel_id) ? "0" : channel_id)).Count() == 0)
                    {
                        json = "{success:true,msg:\""+Resources.Channel.CHANNEL_HAS_EXIST+"。\",channelId:\"" + channel_id + "\"}";

                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_name_simple"]))
                {
                    ch.channel_name_simple = Request.Form["channel_name_simple"].ToString();
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_invoice"]))
                {
                    ch.channel_invoice = Request.Form["channel_invoice"].ToString();
                    u.user_password = Request.Form["channel_invoice"].ToString();
                }

                if (!string.IsNullOrEmpty(Request.Form["channel_email"]))
                {
                    ch.channel_email = Request.Form["channel_email"].ToString();
                }
                else
                {
                    ch.channel_email = "";
                }

                if (!string.IsNullOrEmpty(Request.Form["company_cphonenum"]))
                {
                    ch.company_phone = Request.Form["company_cphone"].ToString() +Request.Form["company_cphonenum"].ToString();
                }
                else
                {
                    ch.company_phone = "";
                }

                if (!string.IsNullOrEmpty(Request.Form["company_cfaxnum"]))
                {
                    ch.company_fax = Request.Form["company_cfax"].ToString() +Request.Form["company_cfaxnum"].ToString();
                }
                else
                {
                    ch.company_fax = "";
                }

                if (!string.IsNullOrEmpty(Request.Form["company_zip"]))
                {
                    ch.company_zip = Int32.Parse(Request.Form["company_zip"].ToString());
                }
                else
                {
                    ch.company_zip = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["company_address"]))
                {
                    ch.company_address = Request.Form["company_address"].ToString();
                }
                else
                {
                    ch.company_address = "";
                }

                if (!string.IsNullOrEmpty(Request.Form["invoice_title"]))
                {
                    ch.invoice_title = Request.Form["invoice_title"].ToString();
                }

                if (!string.IsNullOrEmpty(Request.Form["invoice_zip"]))
                {
                    ch.invoice_zip = Int32.Parse(Request.Form["invoice_zip"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Form["invoice_address"]))
                {
                    ch.invoice_address = Request.Form["invoice_address"].ToString();
                }

                if (!string.IsNullOrEmpty(Request.Form["contract_createdate"]))
                {
                    ch.contract_createdate = DateTime.Parse(Request.Form["contract_createdate"].ToString());
                }
                else
                {
                    ch.contract_createdate = DateTime.MinValue;
                }

                if (!string.IsNullOrEmpty(Request.Form["contract_start"]))
                {
                    ch.contract_start = DateTime.Parse(Request.Form["contract_start"].ToString());
                }
                else
                {
                    ch.contract_start = DateTime.MinValue;
                }

                if (!string.IsNullOrEmpty(Request.Form["contract_end"]))
                {
                    ch.contract_end = DateTime.Parse(Request.Form["contract_end"].ToString());
                }
                else
                {
                    ch.contract_end = DateTime.MinValue;
                }

                if (!string.IsNullOrEmpty(Request.Form["annaul_fee"]))
                {
                    ch.annaul_fee = Decimal.Parse(Request.Form["annaul_fee"].ToString());
                }
                else
                {
                    ch.annaul_fee = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["renew_fee"]))
                {
                    ch.renew_fee = Decimal.Parse(Request.Form["renew_fee"].ToString());
                }
                else
                {
                    ch.renew_fee = 0;
                }

                if (!string.IsNullOrEmpty(Request.Form["model_in"]))
                {
                    ch.model_in = Request.Form["model_in"].ToString();
                }
                else
                {
                    ch.model_in = "1";
                }

                if (!string.IsNullOrEmpty(Request.Form["notify_sms"]))
                {
                    ch.notify_sms = Int32.Parse(Request.Form["notify_sms"].ToString());
                }
                else
                {
                    ch.notify_sms = 0;
                }

                //add by xiangwang0413w 2014/06/26 增加 ERP客戶代號
                if (!string.IsNullOrEmpty(Request.Form["erp_id"]))
                {
                    ch.erp_id = Request.Form["erp_id"];
                }

                DataTable dtUsers = uMgr.Query(Request.Form["manager_Email"].ToString());
                if (dtUsers.Rows.Count > 0)//會員信箱已存在
                {
                    DataTable dtUserId = chMgr.QueryUser(dtUsers.Rows[0]["user_id"].ToString());
                    if (string.IsNullOrEmpty(channel_id))//新增
                    {                        
                        if (dtUserId.Rows.Count > 0)//是否被外站使用
                        {
                            json = "{success:true,msg:\""+Resources.Channel.MAIL_WAS_USED+"。\",channelId:\"" + channel_id + "\"}";

                            this.Response.Clear();
                            this.Response.Write(json);
                            this.Response.End();
                            return this.Response;
                        }
                        else
                        {
                            ch.user_id = Int32.Parse(dtUsers.Rows[0]["user_id"].ToString());
                            channel_id = chMgr.Save(ch).ToString();
                            result = Int32.Parse(channel_id) > 0;
                        }
                    }                    
                    else
                    {
                        //修改
                        if (dtUserId.Rows.Count > 0)
                        {
                            if (dtUserId.Rows[0]["channel_id"].ToString() != channel_id)
                            {
                                json = "{success:true,msg:\"" + Resources.Channel.MAIL_WAS_USED + "。\",channelId:\"" + channel_id + "\"}";

                                this.Response.Clear();
                                this.Response.Write(json);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                ch.user_id = Int32.Parse(dtUsers.Rows[0]["user_id"].ToString());
                            }
                        }
                        else
                        {
                            ch.user_id = Int32.Parse(dtUsers.Rows[0]["user_id"].ToString());
                        }

                        ch.channel_id = Int32.Parse(channel_id);

                        result = chMgr.Edit(ch) > 0;
                    }
                }
                else
                {
                    //會員信箱不存在
                    u.user_email = Request.Form["manager_Email"].ToString();
                    u.user_name = Request.Form["channel_name_full"].ToString();

                    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    u.user_password = hash.SHA256Encrypt(Request.Form["invoice_title"].ToString());

                    u.user_mobile = "0227833183";
                    u.user_phone = "0227833183";
                    u.user_zip = 115;
                    u.user_address = Resources.Channel.USER_ADDRESS;
                    u.user_status = 1;
                    u.user_reg_date = (int)BLL.gigade.Common.CommonFunction.GetPHPTime();
                    u.user_updatedate = (int)BLL.gigade.Common.CommonFunction.GetPHPTime();
                    u.user_birthday_year = 1900;
                    u.user_birthday_month = 01;
                    u.user_birthday_day = 01;

                    if (uMgr.SelSaveID(u) > 0)
                    {
                        ch.user_id = Convert.ToInt32(u.user_id);
                    }
                    if (string.IsNullOrEmpty(channel_id))
                    {
                        channel_id=chMgr.Save(ch).ToString();
                        /**
                         *如果外站類型是gigade,則將參數表中type=deliver_store(即所有物流方式)全部插入channel_shipping表中
                         ***/
                        if (ch.channel_type == 2)
                        {
                            paraMgr = new ParameterMgr(connectString);
                            chsMgr = new ChannelShippingMgr(connectString);
                            List<Parametersrc> Deliver_result = paraMgr.QueryUsed(new Parametersrc { ParameterType = "deliver_store", Used = 1 });
                            foreach (Parametersrc item in Deliver_result)
                            {
                                chs.channel_id = int.Parse(channel_id);
                                chs.shipping_carrior = int.Parse(item.ParameterCode);
                                chs.shipco = item.parameterName;
                                chsMgr.Save(chs);
                            }

                        }
                        /*
                         end by zhongyu0304w at 2013/10/10
                         */
                        result = Int32.Parse(channel_id) > 0;
                    }
                    else
                    {
                        ch.channel_id = int.Parse(channel_id);
                        result = chMgr.Edit(ch) > 0;
                    }
                }

                
                if (result)
                {
                    
                    json = "{success:true,msg:\""+Resources.Channel.SUCCESS+"。\",channelId:\"" + channel_id + "\"}";
                }
                else
                {
                    json = "{success:true,msg:\""+Resources.Channel.FAILED+"\",channelId:\"" + channel_id + "\"}";
                }
            }
            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,msg:\"" + Resources.Channel.FAILED + "\",channelId:\"" + channel_id + "\"}";
            }

            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #7
0
        public string QueryOther()
        {
            chMgr = new ChannelMgr(connectString);

            string json = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(Request.Form["channel_id"]))
                {
                    json = chMgr.QueryOther(Int32.Parse(Request.Form["channel_id"].ToString()));
                }
            }
            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 = "[]";
            }

            return json;
        }