public JsonResult GetAuthorityGroup()
 {
     try
     {
         BLL.gigade.Model.Vendor vendorModel = new BLL.gigade.Model.Vendor();
         vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
         _vendor = new VendorMgr(connectionString);
         string callId = _vendor.GetSingle(vendorModel).vendor_email;
         AuthorityQuery query = new AuthorityQuery { Type = 1, CallId = callId };
         functionGroupMgr = new FunctionVGroupMgr(connectionString);
         List<Function> functions = functionGroupMgr.CallerAuthorityQuery(query);
         var result = from f in functions
                      group f by f.FunctionGroup into fgroup
                      select new { Id = fgroup.Min(m => m.RowId), Text = fgroup.Key };
         return Json(result);
     }
     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);
     }
     return Json("[]");
 }
Beispiel #2
0
 public Vendor GetSingle(Vendor query)
 {
     try
     {
         return _vendorDao.GetSingle(query);
     }
     catch (Exception ex)
     {
         throw new Exception("VendorMgr-->GetSingle-->" + ex.Message, ex);
     }
 }
Beispiel #3
0
        public ActionResult Index()
        {
            HttpCookie cookies = Request.Cookies["vendor"];
            if (cookies != null)
            {
                ViewBag.LoginEmail = cookies["email"];
            }
            else
            {
                ViewBag.LoginEmail = null;
            }

            if (Session["vendor"] != null)
            {
                return RedirectToAction("", "home");
            }
            else
            {
                string vendorid = Request.QueryString["vendor_id"];
                string key = Request.QueryString["key"];
                string keysec = string.Empty;
                if (!string.IsNullOrEmpty(vendorid) && !string.IsNullOrEmpty(key))
                {
                    int vendor_id = Convert.ToInt32(vendorid);
                    _vendorImp = new VendorMgr(connectionString);
                    string str = _vendorImp.GetLoginId(vendor_id);
                    HashEncrypt hmd5 = new HashEncrypt();
                    string mdlogin_id = hmd5.Md5Encrypt(str, "MD5");
                    keysec = hmd5.Md5Encrypt(mdlogin_id + str, "MD5");
                    if (key.ToString().Trim() != keysec.ToString().Trim())
                    {
                        return View();
                    }
                    else
                    {
                        BLL.gigade.Model.Vendor vendor = new BLL.gigade.Model.Vendor();
                        BLL.gigade.Model.Vendor ven = new BLL.gigade.Model.Vendor();
                        vendor.vendor_id = Convert.ToUInt32(vendorid);
                        _vendorImp = new VendorMgr(connectionString);
                        ven = _vendorImp.GetSingle(vendor);
                        ven.vendor_password = "";
                        Session["vendor"] = ven;
                        Session["lgnName"] = ven.vendor_name_simple;
                        return RedirectToAction("", "home");
                    }
                }
                else
                {
                    return View();
                }

            }
        }
 public HttpResponseBase GetAuthorityFun(string id)
 {
     string json = string.Empty;
     try
     {
         BLL.gigade.Model.Vendor vendorModel = new BLL.gigade.Model.Vendor();
         vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
         _vendor = new VendorMgr(connectionString);
         string callId = _vendor.GetSingle(vendorModel).vendor_email;
         AuthorityQuery query = new AuthorityQuery { Type = 1, CallId = callId };
         if (!string.IsNullOrEmpty(id))
         {
             query.RowId = Convert.ToInt32(id);
         }
         functionGroupMgr = new FunctionVGroupMgr(connectionString);
         List<Function> functions = functionGroupMgr.CallerAuthorityQuery(query);
         StringBuilder strJson = new StringBuilder("[");
         foreach (Function fun in functions)
         {
             strJson.Append("{");
             strJson.AppendFormat("text:\"{0}\",url:\"{1}\",id:\"{2}\",iconCls:\"{3}\",leaf:true", fun.FunctionName, fun.FunctionCode, fun.RowId, fun.IconCls);
             strJson.Append("}");
         }
         strJson.Append("]");
         json = strJson.ToString().Replace("}{", "},{");
     }
     catch (Exception ex)
     {
         json = "[]";
         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);
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #5
0
 public DataTable GetVendor(Vendor v)
 {
     try
     {
         return _productDao.GetVendor(v);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductMgr.GetVendor-->" + ex.Message, ex);
     }
 }
Beispiel #6
0
        public string UpdateVendor(Vendor model)
        {
            model.Replace4MySQL();
            StringBuilder strSql = new StringBuilder("");
            try
            {
                strSql.AppendFormat("update  vendor set vendor_code='{0}',vendor_status='{1}',vendor_email='{2}',vendor_name_full='{3}',vendor_name_simple='{4}',vendor_invoice='{5}', ",
                    model.vendor_code, model.vendor_status, model.vendor_email, model.vendor_name_full, model.vendor_name_simple, model.vendor_invoice);
                strSql.AppendFormat("company_phone='{0}',company_fax='{1}',company_person='{2}',company_zip='{3}',company_address='{4}',invoice_zip='{5}',invoice_address='{6}',contact_type_1='{7}',contact_name_1='{8}',contact_phone_1_1='{9}',",
                     model.company_phone, model.company_fax, model.company_person, model.company_zip, model.company_address, model.invoice_zip, model.invoice_address, model.contact_type_1, model.contact_name_1, model.contact_phone_1_1);
                strSql.AppendFormat("contact_phone_2_1='{0}',contact_mobile_1='{1}',contact_email_1='{2}',contact_type_2='{3}',contact_name_2='{4}',contact_phone_1_2='{5}',contact_phone_2_2='{6}',contact_mobile_2='{7}',contact_email_2='{8}',",
                     model.contact_phone_2_1, model.contact_mobile_1, model.contact_email_1, model.contact_type_2, model.contact_name_2, model.contact_phone_1_2, model.contact_phone_2_2, model.contact_mobile_2, model.contact_email_2);
                strSql.AppendFormat("contact_type_3='{0}',contact_name_3='{1}',contact_phone_1_3='{2}',contact_phone_2_3='{3}',contact_mobile_3='{4}',contact_email_3='{5}',contact_type_4='{6}',contact_name_4='{7}',contact_phone_1_4='{8}',",
                    model.contact_type_3, model.contact_name_3, model.contact_phone_1_3, model.contact_phone_2_3, model.contact_mobile_3, model.contact_email_3, model.contact_type_4, model.contact_name_4, model.contact_phone_1_4);
                strSql.AppendFormat("contact_phone_2_4='{0}',contact_mobile_4='{1}',contact_email_4='{2}',contact_type_5='{3}',contact_name_5='{4}',contact_phone_1_5='{5}',contact_phone_2_5='{6}',contact_mobile_5='{7}',contact_email_5='{8}',",
                    model.contact_phone_2_4, model.contact_mobile_4, model.contact_email_4, model.contact_type_5, model.contact_name_5, model.contact_phone_1_5, model.contact_phone_2_5, model.contact_mobile_5, model.contact_email_5);
                strSql.AppendFormat("cost_percent='{0}',creditcard_1_percent='{1}',creditcard_3_percent='{2}',sales_limit='{3}',bonus_percent='{4}',agreement_createdate='{5}',agreement_start='{6}',agreement_end='{7}',checkout_type='{8}',",
                     model.cost_percent, model.creditcard_1_percent, model.creditcard_3_percent, model.sales_limit, model.bonus_percent, model.agreement_createdate, model.agreement_start, model.agreement_end, model.checkout_type);
                strSql.AppendFormat("checkout_other='{0}',bank_code='{1}',bank_name='{2}',bank_number='{3}',bank_account='{4}',freight_low_limit='{5}',freight_low_money='{6}',freight_normal_limit='{7}',freight_normal_money='{8}',",
                    model.checkout_other, model.bank_code, model.bank_name, model.bank_number, model.bank_account, model.freight_low_limit, model.freight_low_money, model.freight_normal_limit, model.freight_normal_money);
                strSql.AppendFormat("freight_return_low_money='{0}',freight_return_normal_money='{1}',vendor_note='{2}',vendor_confirm_code='{3}',vendor_login_attempts='{4}',assist='{5}',dispatch='{6}',product_mode='{7}',",
                    model.freight_return_low_money, model.freight_return_normal_money, model.vendor_note, model.vendor_confirm_code, model.vendor_login_attempts, model.assist, model.dispatch, model.product_mode);
                strSql.AppendFormat("procurement_days='{0}',self_send_days='{1}',stuff_ware_days='{2}',dispatch_days='{3}',", model.procurement_days, model.self_send_days, model.stuff_ware_days, model.dispatch_days);
                strSql.AppendFormat("vendor_type='{0}',", model.vendor_type);//供應商類型
                strSql.AppendFormat("product_manage='{0}',gigade_bunus_percent='{1}',gigade_bunus_threshold='{2}',erp_id='{3}',export_flag='{4}' where vendor_id='{5}';",
                    model.product_manage, model.gigade_bunus_percent, model.gigade_bunus_threshold, model.erp_id, model.export_flag, model.vendor_id);

                return strSql.ToString();
            }
            catch (Exception ex)
            {
                throw new Exception("VendorDao-->UpdateVendor-->" + ex.Message + strSql.ToString(), ex);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 獲取所有有效的供應商(用作下拉列表框)
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<Vendor> VendorQueryAll(Vendor query)
        {
            query.Replace4MySQL();
            StringBuilder sbSql = new StringBuilder();
            try
            {
                sbSql.Append(@" SELECT vendor_id,vendor_code,vendor_status,vendor_email,vendor_password,vendor_name_full,vendor_name_simple,vendor_invoice, 
                company_phone,company_fax,company_person,company_zip,company_address,invoice_zip,invoice_address,contact_type_1,contact_name_1,contact_phone_1_1,
                contact_phone_2_1,contact_mobile_1,contact_email_1,contact_type_2,contact_name_2,contact_phone_1_2,contact_phone_2_2,contact_mobile_2,contact_email_2,
                contact_type_3,contact_name_3,contact_phone_1_3,contact_phone_2_3,contact_mobile_3,contact_email_3,contact_type_4,contact_name_4,contact_phone_1_4,
                contact_phone_2_4,contact_mobile_4,contact_email_4,contact_type_5,contact_name_5,contact_phone_1_5,contact_phone_2_5,contact_mobile_5,contact_email_5,
                cost_percent,creditcard_1_percent,creditcard_3_percent,sales_limit,bonus_percent,agreement_createdate,agreement_start,agreement_end,checkout_type,
                checkout_other,bank_code,bank_name,bank_number,bank_account,freight_low_limit,freight_low_money,freight_normal_limit,freight_normal_money,
                freight_return_low_money,freight_return_normal_money,vendor_note,vendor_confirm_code,vendor_login_attempts,assist,dispatch,product_mode,
                product_manage,gigade_bunus_percent,gigade_bunus_threshold,procurement_days,self_send_days,stuff_ware_days,dispatch_days,vendor_type,kuser,kdate FROM vendor WHERE vendor_status = 1 ");
                if (query.assist != 0)
                {
                    sbSql.AppendFormat(" AND assist = 1 ");
                }

                sbSql.Append(" ORDER BY vendor_id ASC");
                return _dbAccess.getDataTableForObj<Vendor>(sbSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(" vendorDao-->VendorQueryAll-->" + ex.Message + sbSql.ToString(), ex);
            }
        }
 //根據vendorid獲取供應商信息        
 public HttpResponseBase GetVendorDetail()
 {
     List<Vendor> stores = new List<Vendor>();
     Vendor q= new Vendor();
     _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
     string json = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["vid"]))
         {
             q.vendor_id = uint.Parse(Request.Params["vid"].ToString());
             stores = _orderDetailMgr.GetVendor(q);
             json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據
         }
         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,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #9
0
 /// <summary>
 /// 獲取所有供應商(用作下拉列表框)
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public List<Vendor> VendorQueryAll(Vendor query,string AddSql=null)
 {
     StringBuilder sbSql = new StringBuilder();
     try
     {
         sbSql.Append("SELECT vendor_id,vendor_name_simple  FROM vendor where 1=1 ");
         if (!string.IsNullOrEmpty(AddSql))
         {
             sbSql.Append(AddSql);
         }
         //sbSql.Append("  ORDER BY vendor_id ASC");
         return _dbAccess.getDataTableForObj<Vendor>(sbSql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception(" vendorDao-->VendorQueryAll-->" + ex.Message + sbSql.ToString(), ex);
     }
 }
Beispiel #10
0
        public HttpResponseBase QueryContactTable()
        {
            _vendorMgr = new VendorMgr(connectionString);
            DataTable _dt = new DataTable();
            _dt.Columns.Add("contact_type", typeof(string));
            _dt.Columns.Add("contact_name", typeof(string));
            _dt.Columns.Add("contact_phone1", typeof(string));
            _dt.Columns.Add("contact_phone2", typeof(string));
            _dt.Columns.Add("contact_mobile", typeof(string));
            _dt.Columns.Add("contact_email", typeof(string));
            string json = string.Empty;
            #region 字典保存出貨窗口
            Dictionary<uint, string> ContactType = new Dictionary<uint, string>();
            ContactType.Add(1, "負責人");
            ContactType.Add(2, "業務窗口");
            ContactType.Add(3, "圖/文窗口");
            ContactType.Add(4, "出貨負責窗口");
            ContactType.Add(5, "帳務連絡窗口");
            ContactType.Add(6, "客服窗口");
            #endregion
            Vendor ven = new Vendor();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["vendor_id"]))
                {

                    ven.vendor_id = Convert.ToUInt32(Request.QueryString["vendor_id"]);
                    ven = _vendorMgr.GetSingle(ven);

                }
                if (ContactType.Keys.Contains(ven.contact_type_1))
                {
                    DataRow row = _dt.NewRow();
                    row["contact_type"] = "出貨窗口";
                    row["contact_name"] = ven.contact_name_1;
                    row["contact_phone1"] = ven.contact_phone_1_1;
                    row["contact_phone2"] = ven.contact_phone_2_1;
                    row["contact_mobile"] = ven.contact_mobile_1;
                    row["contact_email"] = ven.contact_email_1;
                    _dt.Rows.Add(row);
                }
                if (ContactType.Keys.Contains(ven.contact_type_2))
                {
                    DataRow row = _dt.NewRow();
                    row["contact_type"] = ContactType[ven.contact_type_2];
                    row["contact_name"] = ven.contact_name_2;
                    row["contact_phone1"] = ven.contact_phone_1_2;
                    row["contact_phone2"] = ven.contact_phone_2_2;
                    row["contact_mobile"] = ven.contact_mobile_2;
                    row["contact_email"] = ven.contact_email_2;
                    _dt.Rows.Add(row);
                }
                if (ContactType.Keys.Contains(ven.contact_type_3))
                {
                    DataRow row = _dt.NewRow();
                    row["contact_type"] = ContactType[ven.contact_type_3];
                    row["contact_name"] = ven.contact_name_3;
                    row["contact_phone1"] = ven.contact_phone_1_3;
                    row["contact_phone2"] = ven.contact_phone_2_3;
                    row["contact_mobile"] = ven.contact_mobile_3;
                    row["contact_email"] = ven.contact_email_3;
                    _dt.Rows.Add(row);
                }
                if (ContactType.Keys.Contains(ven.contact_type_4))
                {
                    DataRow row = _dt.NewRow();
                    row["contact_type"] = ContactType[ven.contact_type_4];
                    row["contact_name"] = ven.contact_name_4;
                    row["contact_phone1"] = ven.contact_phone_1_4;
                    row["contact_phone2"] = ven.contact_phone_2_4;
                    row["contact_mobile"] = ven.contact_mobile_4;
                    row["contact_email"] = ven.contact_email_4;
                    _dt.Rows.Add(row);
                }
                if (ContactType.Keys.Contains(ven.contact_type_5))
                {
                    DataRow row = _dt.NewRow();
                    row["contact_type"] = ContactType[ven.contact_type_5];
                    row["contact_name"] = ven.contact_name_5;
                    row["contact_phone1"] = ven.contact_phone_1_5;
                    row["contact_phone2"] = ven.contact_phone_2_5;
                    row["contact_mobile"] = ven.contact_mobile_5;
                    row["contact_email"] = ven.contact_email_5;
                    _dt.Rows.Add(row);
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,'msg':'user',data:" + JsonConvert.SerializeObject(_dt, Formatting.Indented, timeConverter) + "}";//返回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:false,totalCount:0,data:[]}";
            }

            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Beispiel #11
0
        public string QueryContanct(Vendor query)
        {
            try
            {
                Vendor ven = _vendorDao.GetSingle(query);

                StringBuilder stb = new StringBuilder();
                stb.Append("{");
                stb.Append(string.Format("success:true,items:["));
                stb.Append("{");
                stb.Append(string.Format("\"contact_type\":\"{0}\",\"contact_name\":\"{1}\",\"contact_phone1\":\"{2}\",\"contact_phone2\":\"{3}\",\"contact_mobile\":\"{4}\",\"contact_email\":\"{5}\"", ven.contact_type_1, ven.contact_name_1, ven.contact_phone_1_1, ven.contact_phone_2_1, ven.contact_mobile_1, ven.contact_email_1));
                stb.Append("}");
                stb.Append(string.Format("\"contact_type\":\"{0}\",\"contact_name\":\"{1}\",\"contact_phone1\":\"{2}\",\"contact_phone2\":\"{3}\",\"contact_mobile\":\"{4}\",\"contact_email\":\"{5}\"", ven.contact_type_2, ven.contact_name_2, ven.contact_phone_1_2, ven.contact_phone_2_2, ven.contact_mobile_2, ven.contact_email_2));
                stb.Append("}");
                stb.Append(string.Format("\"contact_type\":\"{0}\",\"contact_name\":\"{1}\",\"contact_phone1\":\"{2}\",\"contact_phone2\":\"{3}\",\"contact_mobile\":\"{4}\",\"contact_email\":\"{5}\"", ven.contact_type_3, ven.contact_name_3, ven.contact_phone_1_3, ven.contact_phone_2_3, ven.contact_mobile_3, ven.contact_email_3));
                stb.Append("}");
                stb.Append(string.Format("\"contact_type\":\"{0}\",\"contact_name\":\"{1}\",\"contact_phone1\":\"{2}\",\"contact_phone2\":\"{3}\",\"contact_mobile\":\"{4}\",\"contact_email\":\"{5}\"", ven.contact_type_4, ven.contact_name_4, ven.contact_phone_1_4, ven.contact_phone_2_4, ven.contact_mobile_4, ven.contact_email_4));
                stb.Append("}");
                stb.Append(string.Format("\"contact_type\":\"{0}\",\"contact_name\":\"{1}\",\"contact_phone1\":\"{2}\",\"contact_phone2\":\"{3}\",\"contact_mobile\":\"{4}\",\"contact_email\":\"{5}\"", ven.contact_type_5, ven.contact_name_5, ven.contact_phone_1_5, ven.contact_phone_2_5, ven.contact_mobile_5, ven.contact_email_5));
                stb.Append("}");


                stb.Append("]}");
                return stb.ToString().Replace("}{", "},{");
            }
            catch (Exception ex)
            {
                throw new Exception(" VendorMgr-->QueryContanct-->" + ex.Message, ex);
            }
        }
Beispiel #12
0
        public List<Vendor> VendorQueryList(Vendor query)
        {
            try
            {
                return _vendorDao.VendorQueryList(query);
            }
            catch (Exception ex)
            {

                throw new Exception(" VendorMgr-->VendorQueryList-->" + ex.Message, ex);
            }
        }
Beispiel #13
0
        public ActionResult Login()
        {
            string code = string.Empty;
            string challenge_id = string.Empty;
            string challenge_key = string.Empty;
          
            object notice = new object();
            if (string.IsNullOrEmpty(Request.Params["txtEmail"]))
            {
                notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_EMAIL + "'}";
                ViewBag.notice = notice;
                return View("Index");
            }

            string IsRemember = Request.Params["chkRememberEmail"] != null ? Request.Params["chkRememberEmail"] : "false";
            string email = Request.Params["txtEmail"].Trim();
            string passwd = Request.Params["passwd"].Trim();
            int CookieExpireTime = 10;
            ViewBag.LoginEmail = null;
            _vendorImp = new VendorMgr(connectionString);
            //Caller caller = null;
            BLL.gigade.Model.Vendor vendor = null;
            //記錄/清空cookie

            BLL.gigade.Common.CommonFunction.Cookie_Set("vendor", "email", email, IsRemember, CookieExpireTime);

            UserLoginAttemptsMgr ulaMgr = new UserLoginAttemptsMgr(connectionString);

            //if (!Regex.IsMatch(email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
            if (!Regex.IsMatch(email, @"[\w|-]+@[-|\w]*[-|\.|\w]*\.\w"))
            {
                notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}";
                ViewBag.notice = notice;
                if (IsRemember == "true")
                {
                    ViewBag.LoginEmail = email;
                }
                return View("Index");
            }

            if (passwd == "")
            {
                notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_PASSWD + "'}";
                ViewBag.notice = notice;
                if (IsRemember == "true")
                {
                    ViewBag.LoginEmail = email;
                }
                return View("Index");
            }
            if (!string.IsNullOrEmpty(Request.Params["CheckCode"]))
            {
                code = Request.Params["CheckCode"].ToString().Trim();
            }
            if (Session["code"] != null)
            {
                if (Session["code"].ToString() != code)
                {
                    string message = "{result:'Notice',msg:'驗證碼輸入錯誤'}";
                    ViewBag.notice = message;
                    ViewBag.Email = Request.Params["txtEmail"];
                    ViewBag.Password = Request.Params["passwd"];
                    return View("Index");
                }
            }
            try
            {
                BLL.gigade.Model.Vendor query = new BLL.gigade.Model.Vendor();
                query.vendor_email = email;
                vendor = _vendorImp.Login(query);
            }
            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);
            }


            if (vendor == null)
            {
                notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_PASSWD_ERROR + "'}";
                ViewBag.notice = notice;
                if (IsRemember == "true")
                {
                    ViewBag.LoginEmail = email;
                }
                UserLoginAttempts ula = new UserLoginAttempts();
                ula.login_mail = email;
                ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                ula.login_type = 5;
                ulaMgr.Insert(ula);
                return View("Index");
            }
            else
            {
                if (vendor.vendor_status == 2)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.NOTICE_EMAIL_STOP + "'}";
                    ViewBag.notice = notice;
                    if (IsRemember == "true")
                    {
                        ViewBag.LoginEmail = email;
                    }
                    UserLoginAttempts ula = new UserLoginAttempts();
                    ula.login_mail = email;
                    ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                    ula.login_type = 5;
                    ulaMgr.Insert(ula);
                    ViewBag.Email = Request.Params["txtEmail"];
                    return View("Index");
                }

                //if (caller.user_status == 3)
                //{
                //    notice = "{result:'Error',msg:'" + Resources.Login.NOTICE_EMAIL_DELETE + "'}";
                //    ViewBag.notice = notice;
                //    if (IsRemember == "true")
                //    {
                //        ViewBag.LoginEmail = email;
                //    }
                //    return View("Index");
                //}


                try
                {
                    challenge_id = callerMgr.Add_Challenge();
                    challenge_key = callerMgr.Get_Challenge_Key(challenge_id);
                    callerMgr.Kill_Challenge_Id(challenge_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);
                }
               
                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                string inputpasswd = hash.SHA256Encrypt(hash.SHA256Encrypt(passwd) + challenge_key);
                string newpasswd = hash.SHA256Encrypt(vendor.vendor_password+ challenge_key);

                if (inputpasswd != newpasswd)
                {
                    try
                    {
                        _vendorImp.Add_Login_Attempts(Convert.ToInt32(vendor.vendor_id));
                        //callerMgr.Add_Login_Attempts(caller.user_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);
                    }

                    vendor.vendor_login_attempts++;
                    string tempStr = string.Format(Resources.Login.ERROR_PASSWD_ERROR_TIMES, vendor.vendor_login_attempts, 6);
                    notice = "{result:'Error',msg:'" + tempStr + "'}";
                    UserLoginAttempts ula = new UserLoginAttempts();
                    ula.login_mail = email;
                    ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                    ula.login_type = 5;
                    ulaMgr.Insert(ula);
                    ViewBag.notice = notice;
                    ViewBag.Email = Request.Params["txtEmail"];
                    ViewBag.challenge_id = callerMgr.Add_Challenge();
                    ViewBag.challenge_key = callerMgr.Get_Challenge_Key(ViewBag.challenge_id);

                    if (vendor.vendor_login_attempts >= 6)
                    {
                        try
                        {
                            _vendorImp.Modify_Vendor_Status(Convert.ToInt32(vendor.vendor_id), 2);
                        }
                        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);
                        }

                    }


                    if (IsRemember == "true")
                    {
                        ViewBag.LoginEmail = email;
                    }

                    return View("Index");
                }

                //if (caller.user_status == 0)
                //{
                //    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_FIRST_LOGIN + "'}";
                //    ViewBag.notice = notice;
                //    ViewBag.isFirst = 1;
                //    ViewBag.uid = caller.user_id;
                //    ViewBag.email = caller.user_email;
                //    return View("ChangePasswd");
                //}

                //try
                //{
                //    //添加登錄記錄
                //    callerMgr.Add_Manage_Login(caller.user_id);

                //    //修改登入數據
                //    callerMgr.Modify_User_Login_Data(caller.user_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);
                //}

                //caller.user_password = "";

                //Session["caller"] = caller;
                vendor.vendor_password = "";
                Session["vendor"] = vendor;
                Session["lgnName"] = vendor.vendor_name_simple;
                return Redirect("../home");

            }

        }
Beispiel #14
0
        public ActionResult DoForget()
        {
            object notice = new object();
            if (!string.IsNullOrEmpty(Request.Params["txtEmail"]))
            {
                string _email = Request.Params["txtEmail"].Trim().ToLower();
                if (!Regex.IsMatch(_email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                _vendorImp = new VendorMgr(connectionString);
                //Caller caller = null;
                BLL.gigade.Model.Vendor vendor = null;
                ICallerImplMgr callerMgr = new CallerMgr(connectionString);
                BLL.gigade.Model.Vendor query = new BLL.gigade.Model.Vendor();
                try
                {
                    query.vendor_email = _email;
                    vendor = _vendorImp.Login(query);
                }
                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);
                }

                if (vendor == null)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMIAL_NOT_MATCH + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                if (vendor.vendor_status >= 2)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_STATUS_INACTIVE + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                string sUser_Confirm_Code = BLL.gigade.Common.CommonFunction.Generate_Rand_String(8);

                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();

                try
                {
                    _vendorImp.Modify_Vendor_Confirm_Code(Convert.ToInt32(vendor.vendor_id), hash.SHA256Encrypt(sUser_Confirm_Code));
                }
                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);
                }



                ///////////////////////
                //發郵件
                ///////////////////////

                //return Redirect("/Login/ChangePasswd?uid=" + caller.user_id + "&code=" + sUser_Confirm_Code);

                ViewBag.ConfirmSend = "請檢查您的E-mail信箱,以取得密碼的相關資訊!";
                return View("NoticeShow");

            }
            else
            {
                notice = "{result:'Notice',msg:'登錄信箱不能為空!'}";
                ViewBag.notice = notice;
                return View("Forget");
            }
        }
Beispiel #15
0
        public List<Vendor> GetVendor(Vendor query)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlCondi = new StringBuilder();
            try
            {
                sql.Append(@" select vendor_id,vendor_email,vendor_name_simple,company_phone,company_person from vendor  ");
                if (query.vendor_id > 0)
                {
                    sql.AppendFormat(" where vendor_id='{0}';  ", query.vendor_id);
                }
                return _dbAccess.getDataTableForObj<Vendor>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("OrderDetailDao.GetOrderDetailList -->" + ex.Message + sql.ToString(), ex);
            }

        }
Beispiel #16
0
        public string QueryContact()
        {
            _vendorMgr = new VendorMgr(connectionString);

            string json = string.Empty;
            json = "[]";

            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["vendor_id"]))
                {
                    Vendor ven = new Vendor();
                    ven.vendor_id = Convert.ToUInt32(Request.QueryString["vendor_id"]);
                    json = _vendorMgr.QueryContanct(ven);
                }
            }
            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;
        }
Beispiel #17
0
 /// <summary>
 /// 供應商下拉列表
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 public DataTable GetVendor(Vendor v)
 {
     v.Replace4MySQL();
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"SELECT vendor_id,vendor_name_simple,vendor_name_full FROM vendor WHERE 1=1");
         if (v.assist != 0)
         {
             sql.AppendFormat(@" AND assist = '{0}' ", v.assist);
         }
         sql.AppendFormat(@";");
         return _dbAccess.getDataTable(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ProductDao-->UpdateProductDeatail" + ex.Message + sql.ToString(), ex);
     }
 }
Beispiel #18
0
 public List<Vendor> GetVendor(Vendor query)
 {
     try
     {
         return _orderDetailDao.GetVendor(query);
     }
     catch (Exception ex)
     {
         throw new Exception("OrderDetailMgr-->GetVendor-->" + ex.Message, ex);
     }      
 }
        /// <summary>
        /// 匯出pdf文檔
        /// </summary>
        //public void WritePdf()
        //{
        //    string newName = string.Empty;
        //    string json = string.Empty;
        //    IpodQuery ipod = new IpodQuery();
        //    IpoQuery ipo = new IpoQuery();

        //    if (!string.IsNullOrEmpty(Request.Params["Poid"]))
        //    {
        //        ipo.po_id = Request.Params["Poid"];
        //    }
        //    if (!string.IsNullOrEmpty(Request.Params["Potype"]))
        //    {
        //        ipo.po_type = Request.Params["Potype"];
        //    }
        //    List<IpodQuery> ipodStore = new List<IpodQuery>();
        //    List<IpoQuery> ipoStore = new List<IpoQuery>();
        //    _ipoMgr = new IpoMgr(mySqlConnectionString);
        //    int totalCount = 0;
        //    ipo.IsPage = false;
        //    ipoStore = _ipoMgr.GetIpoList(ipo, out  totalCount);
        //    try
        //    {
        //        #region 採購單匯出

        //        BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
        //        iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
        //        iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
        //        string filename = "採購單"+ DateTime.Now.ToString("yyyyMMddHHmmss") +".pdf";
        //        Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5);
        //        string newPDFName = Server.MapPath(excelPath) + filename;
        //        PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
        //        document.Open();
        //        //運送方式

        //           _paraMgr = new ParameterMgr(mySqlConnectionString);
        //        List<Parametersrc> parameterStore = new List<Parametersrc>();


        //        parameterStore = _paraMgr.GetElementType("product_freight");

        //        for (int a = 0; a < ipoStore.Count; a++)//循環單頭
        //        {
        //            //GetIpodListExprot
        //            _ipodMgr = new IpodMgr(mySqlConnectionString);
        //            ipod = new IpodQuery();
        //            ipod.po_id = ipoStore[a].po_id;
        //            ipodStore = new List<IpodQuery>();
        //            ipodStore = _ipodMgr.GetIpodListExprot(ipod);
        //            Dictionary<int, List<IpodQuery>> product_freight_set_mapping = new Dictionary<int, List<IpodQuery>>();
        //            #region 通過運送方式把採購單分開--一張採購單,分成常溫,冷凍等採購單


        //            for (int i = 0; i < ipodStore.Count; i++)//通過運送方式保存到字典里
        //            {
        //                ipodStore[i].spec = GetProductSpec(ipodStore[i].item_id.ToString());
        //                IupcQuery upc = new IupcQuery();
        //                upc.item_id = ipodStore[i].item_id;
        //                List<IupcQuery> upcStore = new List<IupcQuery>();
        //                _IiupcMgr = new IupcMgr(mySqlConnectionString);
        //                upcStore = _IiupcMgr.GetIupcByItemID(upc);
        //                if (upcStore.Count > 0)
        //                {
        //                    ipodStore[i].upc_id = upcStore[0].upc_id;
        //                }
        //                int freiset = ipodStore[i].product_freight_set;
        //                if (!product_freight_set_mapping.Keys.Contains(freiset))
        //                {
        //                    List<IpodQuery> s = new List<IpodQuery>();
        //                    product_freight_set_mapping.Add(freiset, s);
        //                }
        //                product_freight_set_mapping[freiset].Add(ipodStore[i]);
        //            }
        //            #endregion

        //            #region 針對匯出一個而無商品的pdf


        //            if (ipodStore.Count == 0)
        //            {

        //                #region 獲取供應商信息

        //                Vendor vendor = new Vendor();
        //                _vendorMgr = new VendorMgr(mySqlConnectionString);

        //                vendor.erp_id = ipoStore[a].vend_id;
        //                vendor = _vendorMgr.GetSingle(vendor);
        //                #endregion
        //                #region 採購單標題


        //                PdfContentByte cb = writer.DirectContent;
        //                cb.BeginText();
        //                cb.SetFontAndSize(bf, 15);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地好市集股份有限公司", 220, 790, 0);
        //                font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
        //                cb.SetFontAndSize(bf, 12);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "採購單" + "-" + ipoStore[a].po_type_desc, 280, 770, 0);
        //                cb.SetFontAndSize(bf, 8);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司電話:", 60, 760, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司傳真:", 470, 760, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), 60, 750, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "頁", 510, 750, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "次", 530, 750, 0);
        //                #endregion

        //                PdfPTable ptable = new PdfPTable(6);

        //                ptable.WidthPercentage = 150;//表格寬度
        //                font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
        //                ptable.SetTotalWidth(new float[] { 82, 50, 100, 90, 110, 71 });
        //                PdfPCell cell = new PdfPCell();
        //                cell.UseAscender = true;
        //                cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中
        //                cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中
        //                cell.BorderWidth = 0.1f;
        //                cell.BorderColor = new BaseColor(0, 0, 0);

        //                #region 上部分


        //                cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font));
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("匯率:" + "浮動", font));
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("運輸方式:" , font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);


        //                cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("所在層:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("預約到貨日期:", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("課稅別:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("營業稅率:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("價格條件:", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("廠別代號:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("gigade(讀取)", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("付款條件(讀取)", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("月結N天(讀取):", font));


        //                cell.Colspan = 3;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("廠商全名(讀取):" , font));
        //                cell.Colspan = 4;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("備註:", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);


        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("廠商地址:", font));
        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);


        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(" ", font));
        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);


        //                cell = new PdfPCell(new Phrase("聯絡人(讀取):", font));
        //                cell.Colspan = 2;

        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("廠商電話:" , font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("廠商傳真:" , font));


        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("送貨地址(讀取):", font));



        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(" ", font));




        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font));




        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("配送電話(讀取):", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("配送傳真(讀取):", font));


        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("處理備註:", font));


        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("運送備註:", font));
        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);

        //                ptable.AddCell(cell);
        //                #endregion

        //                ptable.WriteSelectedRows(0, -1, 46, 740, writer.DirectContent);//顯示的開始行,結束航(-1為所有)x坐標,y坐標
        //                PdfPTable nulltable = new PdfPTable(2);
        //                nulltable.SetWidths(new int[] { 20, 20 });
        //                nulltable.DefaultCell.DisableBorderSide(1);
        //                nulltable.DefaultCell.DisableBorderSide(2);
        //                nulltable.DefaultCell.DisableBorderSide(4);
        //                nulltable.DefaultCell.DisableBorderSide(8);
        //                nulltable.AddCell("");
        //                nulltable.AddCell("");
        //                nulltable.SpacingAfter = 292;
        //                document.Add(nulltable);
        //                ptable = new PdfPTable(6);
        //                ptable.WidthPercentage = 86;//表格寬度
        //                font = new iTextSharp.text.Font(bf, 9, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
        //                ptable.SetTotalWidth(new float[] { 90, 130, 50, 50, 60, 120 });
        //                cell = new PdfPCell(new Phrase("此採購單商品不存在!", font));


        //                cell.Colspan = 6;

        //                ptable.AddCell(cell);
        //                cb.EndText();
        //                document.Add(ptable);
        //                document.NewPage();


        //            }
        //            #endregion

        //            foreach (int key in product_freight_set_mapping.Keys)
        //            {
        //                #region 取出運送方式
        //                string procduct_freight = "";
        //                for (int i = 0; i < parameterStore.Count; i++)
        //                {
        //                    if (key.ToString() == parameterStore[i].ParameterCode)
        //                    {
        //                        procduct_freight = parameterStore[i].parameterName;
        //                    }
        //                }
        //                #endregion

        //                #region 獲取供應商信息

        //               Vendor vendor = new Vendor();
        //               _vendorMgr = new VendorMgr(mySqlConnectionString);

        //               vendor.erp_id = ipoStore[a].vend_id;
        //               vendor = _vendorMgr.GetSingle(vendor);
        //                #endregion
        //                #region 採購單標題


        //                PdfContentByte cb = writer.DirectContent;
        //                cb.BeginText();
        //                cb.SetFontAndSize(bf, 15);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地好市集股份有限公司", 220, 790, 0);
        //                font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
        //                cb.SetFontAndSize(bf, 12);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "採購單" + "-" + ipoStore[a].po_type_desc, 280, 770, 0);
        //                cb.SetFontAndSize(bf, 8);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司電話:", 60, 760, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司傳真:", 470, 760, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), 60, 750, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "頁", 510, 750, 0);
        //                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "次", 530, 750, 0);
        //               #endregion

        //                PdfPTable ptable = new PdfPTable(6);

        //                ptable.WidthPercentage = 150;//表格寬度
        //                font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
        //                ptable.SetTotalWidth(new float[] { 82, 50, 100, 90, 110, 71 });
        //                PdfPCell cell = new PdfPCell();
        //                cell.UseAscender = true;
        //                cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中
        //                cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中
        //                cell.BorderWidth = 0.1f;
        //                cell.BorderColor = new BaseColor(0, 0, 0);


        //                #region 上部分


        //                cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font));
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("匯率:" + "浮動", font));
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("運輸方式:" + procduct_freight, font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);


        //                cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("所在層:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("預約到貨日期:", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("課稅別:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("營業稅率:", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("價格條件:", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("廠別代號:" , font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("gigade(讀取)", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(vendor == null ? "暫無此信息" : vendor.vendor_name_simple, font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("付款條件(讀取)", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("月結N天(讀取):", font));


        //                cell.Colspan = 3;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(vendor == null ? "廠商全名(讀取):暫無此信息" :"廠商全名:"+ vendor.vendor_name_full, font));
        //                cell.Colspan = 4;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("備註:", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);


        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(vendor == null ? "廠商地址:暫無此信息" : "廠商地址:"+vendor.company_address, font));
        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);


        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(" ", font));
        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);


        //                cell = new PdfPCell(new Phrase("聯絡人(讀取):", font));
        //                cell.Colspan = 2;

        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(vendor == null?"廠商電話:暫無此信息" :"廠商電話:"+ vendor.company_phone, font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(vendor == null? "廠商傳真:暫無此信息" :"廠商傳真:"+ vendor.company_fax, font));


        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("送貨地址(讀取):", font));



        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase(" ", font));




        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font));




        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("配送電話(讀取):", font));
        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                cell.DisableBorderSide(8);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("配送傳真(讀取):", font));


        //                cell.Colspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("處理備註:", font));


        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("運送備註:", font));
        //                cell.Colspan = 6;
        //                cell.DisableBorderSide(1);

        //                ptable.AddCell(cell);
        //                #endregion


        //                ptable.WriteSelectedRows(0, -1, 46, 740, writer.DirectContent);//顯示的開始行,結束航(-1為所有)x坐標,y坐標
        //                PdfPTable nulltable = new PdfPTable(2);
        //                nulltable.SetWidths(new int[] { 20, 20 });
        //                nulltable.DefaultCell.DisableBorderSide(1);
        //                nulltable.DefaultCell.DisableBorderSide(2);
        //                nulltable.DefaultCell.DisableBorderSide(4);
        //                nulltable.DefaultCell.DisableBorderSide(8);
        //                nulltable.AddCell("");
        //                nulltable.AddCell("");
        //                nulltable.SpacingAfter = 292;
        //                document.Add(nulltable);
        //                ptable = new PdfPTable(6);
        //                ptable.WidthPercentage = 86;//表格寬度
        //                font = new iTextSharp.text.Font(bf, 9, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
        //                ptable.SetTotalWidth(new float[] { 90, 130, 50, 50, 60, 120 });
        //                #region 下面表格頭部

        //                cell = new PdfPCell(new Phrase("條碼", font));
        //                cell.Rowspan = 2;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("品號", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("採購數量", font));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("允收天數", font));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("製造日期", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("備註", font));
        //                cell.Rowspan = 3;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);




        //                cell = new PdfPCell(new Phrase("品名", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("允收數量", font));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("允出天數", font));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(2);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("有效日期", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(4);
        //                cell.Rowspan = 2;
        //                ptable.AddCell(cell);



        //                cell = new PdfPCell(new Phrase("料位", font));
        //                cell.DisableBorderSide(1);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("規格", font));
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("不允收數量", font));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);
        //                cell = new PdfPCell(new Phrase("有效期天數", font));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                cell.DisableBorderSide(1);
        //                cell.DisableBorderSide(4);
        //                ptable.AddCell(cell);


        //                #endregion
        //                _ipodMgr = new IpodMgr(mySqlConnectionString);
        //                ipod = new IpodQuery();
        //                ipod.po_id = ipoStore[a].po_id;
        //                ipod.IsPage = false;
        //                ipodStore = new List<IpodQuery>();
        //                ipodStore = _ipodMgr.GetIpodList(ipod, out totalCount);


        //                List<IpodQuery> Ipodleibie = new List<IpodQuery>();
        //                Ipodleibie.AddRange(product_freight_set_mapping[key]);

        //                #region 循環讀取數據填入表格


        //                for (int i = 0; i < Ipodleibie.Count; i++)
        //                {
        //                    //string sResult = "";
        //                    //if (ipodStore[i].pod_id.ToString().Length < 4)
        //                    //{
        //                    //    for (int n = 0; n < 4 - (ipodStore[i].pod_id.ToString().Length); n++)
        //                    //    {
        //                    //        sResult += "0";
        //                    //    }

        //                    //}
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].upc_id, font));//條碼
        //                    cell.Rowspan = 2;
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].Erp_Id.ToString(), font));//品號
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].qty_ord.ToString(), font));//採購數量qty_ord
        //                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].cde_dt_var.ToString(), font));//允收天數cde_dt_var
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase("", font));//製造日期
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase("", font));//備註
        //                    cell.Rowspan = 3;
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);




        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].product_name, font));//品名
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].qty_claimed.ToString(), font));//允收數量
        //                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].cde_dt_shp.ToString(), font));//允出天數
        //                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER);
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(2);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase("", font));//有效日期
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(4);
        //                    cell.Rowspan = 2;
        //                    ptable.AddCell(cell);



        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].loc_id, font));//料位
        //                    cell.DisableBorderSide(1);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].spec, font));//規格
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].qty_damaged.ToString(), font));//不允收數量
        //                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                    cell = new PdfPCell(new Phrase(Ipodleibie[i].cde_dt_incr.ToString(), font));//有效期天數
        //                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                    cell.DisableBorderSide(1);
        //                    cell.DisableBorderSide(4);
        //                    ptable.AddCell(cell);
        //                }
        //                #endregion

        //                //cell = new PdfPCell(new Phrase(" 數量合計:" + 5, font));
        //                //cell.Colspan = 2;

        //                //cell.DisableBorderSide(1);

        //                //cell.DisableBorderSide(8);
        //                //cell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                //ptable.AddCell(cell);
        //                //cell = new PdfPCell(new Phrase(" 採購金額:", font));
        //                //cell.Colspan = 2;
        //                //cell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                //cell.DisableBorderSide(1);

        //                //cell.DisableBorderSide(4);
        //                //cell.DisableBorderSide(8);
        //                //ptable.AddCell(cell);
        //                //cell = new PdfPCell(new Phrase(" 稅額:", font));
        //                //cell.Colspan = 2;
        //                //cell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                //cell.DisableBorderSide(1);

        //                //cell.DisableBorderSide(4);
        //                //ptable.AddCell(cell);
        //                //cell = new PdfPCell(new Phrase(" 金額合計:", font));
        //                //cell.Colspan = 2;

        //                //cell.DisableBorderSide(1);
        //                //cell.DisableBorderSide(4);

        //                //ptable.AddCell(cell);
        //                //Sumtable.AddCell(ptable);

        //                cb.EndText();
        //                // Sumtable.SpacingAfter = 0;
        //                ptable.SpacingAfter = 250;
        //                //Sumtable.WriteSelectedRows(0, -1, 60, 740, writer.DirectContent);//顯示的開始行,結束航(-1為所有)x坐標,y坐標
        //                document.Add(ptable);
        //                document.NewPage();


        //            }






        //    }


        //        document.Close();
        //        writer.Resume();

        //        Response.Clear();
        //        Response.Charset = "gb2312";
        //        Response.ContentEncoding = System.Text.Encoding.UTF8;
        //        Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename);
        //        Response.WriteFile(newPDFName);
        //        //}
        //        #endregion


        //        //}
        //    }
        //    catch (Exception ex)
        //    {
        //        //cb.EndText();
        //        //writer.Resume();
        //        //Response.Clear();

        //    }
        //}
        public void WritePdf()
        {
            PdfHelper pdf = new PdfHelper();
            List<string> pdfList = new List<string>();
            //float[] arrColWidth_pftable = new float[] { 30,100, 80, 60, 60, 60, 60 };
            float[] arrColWidth = new float[] { 30, 100, 80, 60, 60, 60, 60 };
            int index = 0;
            string newFileName = string.Empty;
            string newName = string.Empty;
            string json = string.Empty;
            IpodQuery ipod = new IpodQuery();
            IpoQuery ipo = new IpoQuery();

            if (!string.IsNullOrEmpty(Request.Params["Poid"]))
            {
                ipo.po_id = Request.Params["Poid"];
            }
            if (!string.IsNullOrEmpty(Request.Params["Potype"]))
            {
                ipo.po_type = Request.Params["Potype"];
            }
            if (!string.IsNullOrEmpty(Request.Params["start_time"]))
            {
                ipo.start_time = Convert.ToDateTime(Request.Params["start_time"].ToString());
            }
            if (!string.IsNullOrEmpty(Request.Params["end_time"]))
            {
                ipo.end_time = Convert.ToDateTime(Request.Params["end_time"].ToString());
            }
            if (!string.IsNullOrEmpty(Request.Params["freight"]))
            {
                ipo.freight = Convert.ToInt32(Request.Params["freight"].ToString());
            }
            List<IpodQuery> ipodStore = new List<IpodQuery>();
            List<IpoQuery> ipoStore = new List<IpoQuery>();
            _ipoMgr = new IpoMgr(mySqlConnectionString);
            int totalCount = 0;
            ipo.IsPage = false;
            ipoStore = _ipoMgr.GetIpoList(ipo, out  totalCount);
            //if (!string.IsNullOrEmpty(Request.Params["freight"]))
            //{
            //    if (Request.Params["freight"].ToString() != "0")
            //    {
            //        _ipodMgr = new IpodMgr(mySqlConnectionString);
            //        List<IpoQuery> newstore = new List<IpoQuery>();
            //        foreach (IpoQuery item in ipoStore)
            //        {
            //            if (!string.IsNullOrEmpty(item.po_id))
            //            {
            //                if (_ipodMgr.GetIpodfreight(item.po_id, Convert.ToInt32(Request.Params["freight"].ToString())))
            //                {
            //                    newstore.Add(item);
            //                }
            //            }
            //        }
            //        ipoStore = newstore;
            //    }
            //}
            try
            {
                #region 採購單匯出

                BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
                iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
                string filename = "採購單" + DateTime.Now.ToString("yyyyMMddHHmmss");
                Document document = new Document(PageSize.A4);
                string newPDFName = Server.MapPath(excelPath) + filename;
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
                document.Open();
                //運送方式

                _paraMgr = new ParameterMgr(mySqlConnectionString);
                List<Parametersrc> parameterStore = new List<Parametersrc>();


                parameterStore = _paraMgr.GetElementType("product_freight");
                if (ipoStore.Count == 0)
                {

                }
                for (int a = 0; a < ipoStore.Count; a++)//循環單頭
                {
                    _ipodMgr = new IpodMgr(mySqlConnectionString);
                    ipod = new IpodQuery();
                    ipod.po_id = ipoStore[a].po_id;
                    ipodStore = new List<IpodQuery>();
                    ipodStore = _ipodMgr.GetIpodListExprot(ipod);
                    Dictionary<int, List<IpodQuery>> product_freight_set_mapping = new Dictionary<int, List<IpodQuery>>();
                    #region 通過運送方式把採購單分開--一張採購單,分成常溫,冷凍等採購單


                    for (int i = 0; i < ipodStore.Count; i++)//通過運送方式保存到字典里
                    {
                        ipodStore[i].spec = GetProductSpec(ipodStore[i].prod_id.ToString());//--------取值出錯了item_id-----------
                        IupcQuery upc = new IupcQuery();
                        _IiupcMgr = new IupcMgr(mySqlConnectionString);

                        upc.item_id = uint.Parse(ipodStore[i].prod_id);//--------取值出錯了item_id-----------
                        //獲取國際條碼
                        List<IupcQuery> upcInternationalStore = new List<IupcQuery>();
                        upc.upc_type_flg = "1";
                        upcInternationalStore = _IiupcMgr.GetIupcByType(upc);
                        //獲取店內條碼
                        List<IupcQuery> upcShopStore = new List<IupcQuery>();
                        upc.upc_type_flg = "3";
                        upcShopStore = _IiupcMgr.GetIupcByType(upc);
                        if (upcInternationalStore.Count > 0)
                        {
                            ipodStore[i].upc_id_international = upcInternationalStore[0].upc_id;
                        }
                        if (upcShopStore.Count > 0)
                        {
                            ipodStore[i].upc_id_shop = upcShopStore[0].upc_id;
                        }
                        int freiset = ipodStore[i].product_freight_set;
                        if (!product_freight_set_mapping.Keys.Contains(freiset))
                        {
                            List<IpodQuery> s = new List<IpodQuery>();
                            product_freight_set_mapping.Add(freiset, s);
                        }
                        product_freight_set_mapping[freiset].Add(ipodStore[i]);
                    }
                    #endregion

                    #region 針對匯出一個而無商品的pdf
                    if (ipodStore.Count == 0)
                    {

                        #region 獲取供應商信息

                        Vendor vendor = new Vendor();
                        _vendorMgr = new VendorMgr(mySqlConnectionString);

                        vendor.erp_id = ipoStore[a].vend_id;
                        vendor = _vendorMgr.GetSingle(vendor);
                        #endregion
                        #region 採購單標題

                        PdfPTable ptable = new PdfPTable(7);


                        ptable.WidthPercentage = 100;//表格寬度
                        font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
                        ptable.SetTotalWidth(arrColWidth);
                        PdfPCell cell = new PdfPCell();

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("    吉甲地好市集股份有限公司", new iTextSharp.text.Font(bf, 15)));
                        cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                        cell.Colspan = 5;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("採購單" + "-" + ipoStore[a].po_type_desc, new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("公司電話:", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 6;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("公司傳真:", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell.UseAscender = true;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中
                        cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中
                        cell.BorderWidth = 0.1f;
                        cell.BorderColor = new BaseColor(0, 0, 0);

                        #endregion
                        #region 上部分


                        cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("匯率:" + "浮動", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("運輸方式:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);


                        cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("所在層:", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("預約到貨日期:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("課稅別:", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("營業稅率:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("價格條件:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("廠別代號:", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("gigade(讀取)", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("付款條件(讀取)", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("月結N天(讀取):", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("廠商全名(讀取):", font));
                        cell.Colspan = 5;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("備註:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);


                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("廠商地址:", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);


                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase(" ", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);


                        cell = new PdfPCell(new Phrase("聯絡人(讀取):", font));
                        cell.Colspan = 2;

                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("廠商電話:", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("廠商傳真:", font));
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("送貨地址(讀取):", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(" ", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("配送電話(讀取):", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("配送傳真(讀取):", font));
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("處理備註:", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("運送備註:", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);

                        ptable.AddCell(cell);
                        #endregion

                        cell = new PdfPCell(new Phrase("此採購單商品不存在!", font));
                        cell.Colspan = 7;

                        ptable.AddCell(cell);

                        newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                        pdf.ExportDataTableToPDF(newFileName, ptable, "", "");
                        pdfList.Add(newFileName);

                        document.Add(ptable);
                        document.NewPage();


                    }
                    #endregion

                    foreach (int key in product_freight_set_mapping.Keys)
                    {
                        #region 取出運送方式
                        string procduct_freight = "";
                        for (int i = 0; i < parameterStore.Count; i++)
                        {
                            if (key.ToString() == parameterStore[i].ParameterCode)
                            {
                                procduct_freight = parameterStore[i].parameterName;
                            }
                        }
                        #endregion

                        #region 獲取供應商信息

                        Vendor vendor = new Vendor();
                        _vendorMgr = new VendorMgr(mySqlConnectionString);

                        vendor.erp_id = ipoStore[a].vend_id;
                        vendor = _vendorMgr.GetSingle(vendor);
                        #endregion

                        #region 採購單標題


                        PdfPTable ptable = new PdfPTable(7);


                        ptable.WidthPercentage = 100;//表格寬度
                        font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
                        ptable.SetTotalWidth(arrColWidth);
                        PdfPCell cell = new PdfPCell();

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("      吉甲地好市集股份有限公司", new iTextSharp.text.Font(bf, 15)));
                        cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                        cell.Colspan = 5;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("    採購單" + "-" + ipoStore[a].po_type_desc, new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("公司電話:", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 6;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("公司傳真:", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8)));
                        cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell.UseAscender = true;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中
                        cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中
                        cell.BorderWidth = 0.1f;
                        cell.BorderColor = new BaseColor(0, 0, 0);
                        #endregion

                        #region 上部分


                        cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("匯率:" + "浮動", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        if (procduct_freight != "常溫" && procduct_freight != "冷凍")
                        {
                            ;
                        }
                        cell = new PdfPCell(new Phrase("運輸方式:" + procduct_freight, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);


                        cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("所在層:", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("預約到貨日期:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("課稅別:", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("營業稅率:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("價格條件:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("採購人員:", font));
                        //cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("廠別代號:", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("gigade(讀取)", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase(vendor == null ? "暫無此信息" : vendor.vendor_name_simple, font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("付款條件(讀取)", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("月結N天(讀取):", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(vendor == null ? "廠商全名(讀取):暫無此信息" : "廠商全名:" + vendor.vendor_name_full, font));
                        cell.Colspan = 5;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("備註:", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);


                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase(vendor == null ? "廠商地址:暫無此信息" : "廠商地址:" + vendor.company_address, font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);


                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase(" ", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);


                        cell = new PdfPCell(new Phrase("聯絡人(讀取):", font));
                        cell.Colspan = 2;

                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase(vendor == null ? "廠商電話:暫無此信息" : "廠商電話:" + vendor.company_phone, font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase(vendor == null ? "廠商傳真:暫無此信息" : "廠商傳真:" + vendor.company_fax, font));


                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("送貨地址(讀取):", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(" ", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font));
                        cell.Colspan = 2;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("配送電話(讀取):", font));
                        cell.Colspan = 1;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("配送傳真(讀取):", font));


                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("處理備註:", font));


                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("運送備註:", font));
                        cell.Colspan = 7;
                        cell.DisableBorderSide(1);

                        ptable.AddCell(cell);
                        #endregion
                        #region 下面表格頭部
                        cell = new PdfPCell(new Phrase("序號", font));
                        cell.VerticalAlignment = Element.ALIGN_MIDDLE;
                        //cell.DisableBorderSide(2);
                        cell.Rowspan = 3;
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("國際條碼", font));
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("品號", font));
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("採購數量", font));
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("允收天數", font));
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("製造日期", font));
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("備註", font));
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("供應商店內碼", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("品名", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("允收數量", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("允出天數", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("有效日期", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("料位", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("規格", font));
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("不允收數量", font));
                        cell.DisableBorderSide(1);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("有效期天數", font));
                        cell.DisableBorderSide(1);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("", font));
                        cell.DisableBorderSide(1);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("", font));
                        cell.DisableBorderSide(1);
                        ptable.AddCell(cell);

                        #endregion

                        _ipodMgr = new IpodMgr(mySqlConnectionString);
                        ipod = new IpodQuery();
                        ipod.po_id = ipoStore[a].po_id;
                        ipod.IsPage = false;
                        ipodStore = new List<IpodQuery>();
                        ipodStore = _ipodMgr.GetIpodList(ipod, out totalCount);

                        List<IpodQuery> Ipodleibie = new List<IpodQuery>();
                        Ipodleibie.AddRange(product_freight_set_mapping[key]);

                        #region 循環讀取數據填入表格
                        DataTable Ipod_dt = new DataTable();
                        Ipod_dt.Columns.Add("序號", typeof(string));
                        Ipod_dt.Columns.Add("國際條碼", typeof(string));
                        Ipod_dt.Columns.Add("品號", typeof(string));
                        Ipod_dt.Columns.Add("採購數量", typeof(string));
                        Ipod_dt.Columns.Add("允收天數", typeof(string));
                        Ipod_dt.Columns.Add("製造日期", typeof(string));
                        Ipod_dt.Columns.Add("備註", typeof(string));
                        Ipod_dt.Columns.Add("Empty_1", typeof(string));
                        Ipod_dt.Columns.Add("供應商店內碼", typeof(string));
                        Ipod_dt.Columns.Add("品名", typeof(string));
                        Ipod_dt.Columns.Add("允收數量", typeof(string));
                        Ipod_dt.Columns.Add("允出天數", typeof(string));
                        Ipod_dt.Columns.Add("有效日期", typeof(string));
                        Ipod_dt.Columns.Add("Empty_3", typeof(string));
                        Ipod_dt.Columns.Add("Empty_4", typeof(string));
                        Ipod_dt.Columns.Add("料位", typeof(string));
                        Ipod_dt.Columns.Add("規格", typeof(string));
                        Ipod_dt.Columns.Add("不允收數量", typeof(string));
                        Ipod_dt.Columns.Add("有效期天數", typeof(string));
                        Ipod_dt.Columns.Add("Empty_5", typeof(string));
                        Ipod_dt.Columns.Add("Empty_6", typeof(string));

                        for (int i = 0; i < Ipodleibie.Count; i++)
                        {
                            DataRow newRow = Ipod_dt.NewRow();
                            newRow["國際條碼"] = Ipodleibie[i].upc_id_international;
                            newRow["品號"] = Ipodleibie[i].Erp_Id.ToString();
                            newRow["採購數量"] = Ipodleibie[i].qty_ord.ToString();
                            newRow["允收天數"] = Ipodleibie[i].cde_dt_var.ToString();
                            newRow["製造日期"] = "";
                            newRow["備註"] = "";
                            newRow["Empty_1"] = (i + 1).ToString(); //序號
                            newRow["供應商店內碼"] = Ipodleibie[i].upc_id_shop;
                            newRow["品名"] = Ipodleibie[i].product_name;
                            newRow["允收數量"] = Ipodleibie[i].qty_claimed.ToString();
                            newRow["允出天數"] = Ipodleibie[i].cde_dt_shp.ToString();
                            newRow["有效日期"] = "";
                            newRow["Empty_3"] = "";
                            newRow["Empty_4"] = "";
                            newRow["料位"] = Ipodleibie[i].loc_id;
                            newRow["規格"] = Ipodleibie[i].spec;
                            newRow["不允收數量"] = Ipodleibie[i].qty_damaged.ToString();
                            newRow["有效期天數"] = Ipodleibie[i].cde_dt_incr.ToString();
                            newRow["Empty_5"] = "";
                            newRow["Empty_6"] = "";
                            Ipod_dt.Rows.Add(newRow);
                        }

                        #endregion
                        ////////
                        newFileName = newPDFName + "_part" + index++ + "." + "pdf";

                        pdf.ExportDataTableToPDF(Ipod_dt, false, newFileName, arrColWidth, ptable, "", "", 7, 7);/*第一7是列,第二個是行*/
                        pdfList.Add(newFileName);

                    }






                }
                newFileName = newPDFName + "." + "pdf";
                pdf.MergePDF(pdfList, newFileName);

                Response.Clear();
                Response.Charset = "gb2312";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf");
                Response.WriteFile(newFileName);
                //}
                #endregion
            }
            catch (Exception ex)
            {
                //cb.EndText();
                //writer.Resume();
                //Response.Clear();

            }
        }
Beispiel #20
0
 public HttpResponseBase GetVendor()
 {
     Vendor v = new Vendor();
     string json = string.Empty;
     try
     {
         _productMgr = new ProductMgr(connectionString);
         DataTable dt = _productMgr.GetVendor(v);
         json = "{success:true,data:" + JsonConvert.SerializeObject(dt, Formatting.Indented) + "}";//返回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:false,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
        // 廠商下拉列表
        public HttpResponseBase GetVendorName()
        {
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            List<Vendor> stores = new List<Vendor>();
            string json = string.Empty;
            try
            {
                Vendor query = new Vendor();
                stores = _IiplasMgr.VendorQueryAll(query);

                query.vendor_name_simple = "所有廠商名稱";
                stores.Insert(0, query);
                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;
        }
Beispiel #22
0
        /// <summary>
        /// 獲取一條供應商信息
        /// </summary>
        /// <param name="query">查詢條件</param>
        /// <returns>供應商信息對象</returns>
        public Vendor GetSingle(Vendor query)
        {
            StringBuilder strSql = new StringBuilder();
            try
            {
                query.Replace4MySQL();
                strSql.Append(" select vendor_id,vendor_code,vendor_status,vendor_email,vendor_password,vendor_name_full,vendor_name_simple,vendor_invoice,");
                strSql.Append("company_phone,company_fax,company_person,company_zip,company_address,invoice_zip,invoice_address,contact_type_1,contact_name_1,contact_phone_1_1,");
                strSql.Append("contact_phone_2_1,contact_mobile_1,contact_email_1,contact_type_2,contact_name_2,contact_phone_1_2,contact_phone_2_2,contact_mobile_2,contact_email_2,");
                strSql.Append("contact_type_3,contact_name_3,contact_phone_1_3,contact_phone_2_3,contact_mobile_3,contact_email_3,contact_type_4,contact_name_4,contact_phone_1_4,");
                strSql.Append("contact_phone_2_4,contact_mobile_4,contact_email_4,contact_type_5,contact_name_5,contact_phone_1_5,contact_phone_2_5,contact_mobile_5,contact_email_5,");
                strSql.Append("cost_percent,creditcard_1_percent,creditcard_3_percent,sales_limit,bonus_percent,agreement_createdate,agreement_start,agreement_end,checkout_type,");
                strSql.Append("checkout_other,bank_code,bank_name,bank_number,bank_account,freight_low_limit,freight_low_money,freight_normal_limit,freight_normal_money,erp_id,");
                strSql.Append("freight_return_low_money,freight_return_normal_money,vendor_note,vendor_confirm_code,vendor_login_attempts,assist,dispatch,product_mode,");//新增字段kuser、kdate保存供應商建立信息 add by shuangshuang0420j 20150624 10:15
                strSql.Append("product_manage,gigade_bunus_percent,gigade_bunus_threshold,procurement_days,self_send_days,stuff_ware_days,dispatch_days,vendor_type,kuser,kdate from vendor where 1=1");//新增字段procurement_days,self_send_days,stuff_ware_days,dispatch_days add by shuangshuang0420j 20150323 10:15
                if (query.vendor_id != 0)
                {
                    strSql.AppendFormat(" and vendor_id={0}", query.vendor_id);
                }
                if (!string.IsNullOrEmpty(query.vendor_email))
                {
                    strSql.AppendFormat(" and vendor_email='{0}'", query.vendor_email);
                }
                if (!string.IsNullOrEmpty(query.erp_id))
                {
                    strSql.AppendFormat(" and erp_id='{0}'", query.erp_id);
                }

                return _dbAccess.getSinggleObj<Vendor>(strSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(" vendorDao-->GetSingle-->" + ex.Message + strSql.ToString(), ex);
            }
        }
        /// <summary>
        /// 供應商後台:訂單管理>供應商調度出貨>要出的貨物信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase AllOrderDeliver()
        {
            uint Normal_Subtotal = 0;//常溫商品總額--
            uint Hypothermia_Subtotal = 0;//低溫商品總額---
            uint All_Normal_Subtotal = 0;//當日常溫運費總額
            uint All_Hypothermia_Subtotal = 0;//當日低溫運費總額
            uint Order_Freight_Normal = 0;//常溫運費
            uint Order_Freight_Low = 0;//低溫運費
            uint All_Order_Freight_Normal = 0;//當日常溫運費--
            uint All_Order_Freight_Low = 0;//當日低溫運費--

            string json = string.Empty;
            try
            {
                string detail_id = "";
                if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
                {
                    detail_id = Request.Params["rowIDs"];
                }
                detail_id = detail_id.TrimEnd(',');//去掉最後一個分割符號
                string[] Sid_Row = detail_id.Split(',');//拆分
                string Sid = Sid_Row[Sid_Row.Length - 1];//獲取最後一個計算出出貨時間
                //通過sid去order_slave查詢order_id;
                //通過order_id查詢在order_master中order_date_pay。
                OrderSlaveQuery query = new OrderSlaveQuery();
                query.Slave_Id = uint.Parse(Sid);
                _IOrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString);
                DateTime time = _IOrderSlaveMgr.GetOrderDatePay(query).order_date_pay;
                long endtime = CommonFunction.GetPHPTime(time.ToString("yyyy/MM/dd 23:59:59"));
                uint vendor_id = (Session["vendor"] as BLL.gigade.Model.Vendor).vendor_id;
                //(計算這些數據參照自vendor.gigade100.com/order/all_order_deliver.php 第209~266行)
                #region 計算供應商當天的常溫和冷凍的總運費
                List<OrderDetailQuery> query1 = new List<OrderDetailQuery>();
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                query1 = _OrderDetailMgr.GetOrderDetailToSum(vendor_id, endtime);

                foreach (var item in query1)
                {
                    if (item.item_mode == 1)
                        continue;
                    if (item.Product_Freight_Set == PRODUCT_FREIGHT_NORMAL || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_NORMAL)//常溫,常溫免運
                    {
                        if (item.item_mode == 2)//組合商品
                        {
                            All_Normal_Subtotal += item.Single_Price * item.parent_num;
                        }
                        else
                        {
                            All_Normal_Subtotal += item.Single_Price * item.Buy_Num;
                        }
                    }
                    else if (item.Product_Freight_Set == PRODUCT_FREIGHT_LOW || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_LOW) //冷凍,冷凍免運
                    {
                        if (item.item_mode == 2)//組合商品
                        {
                            All_Hypothermia_Subtotal += item.Single_Price * item.parent_num;
                        }
                        else
                        {
                            All_Hypothermia_Subtotal += item.Single_Price * item.Buy_Num;
                        }
                    }
                }
                #endregion

                #region 計算運費


                OrderDetailQuery oddquery = new OrderDetailQuery();
                oddquery.Vendor_Id = vendor_id;
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int total = 0;

                string sq = string.Format(" AND os.slave_id in ({0}) ORDER BY od.slave_id ASC ,od. combined_mode ASC , od.item_mode ASC ", detail_id);
                List<OrderDetailQuery> query2 = new List<OrderDetailQuery>();
                oddquery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                oddquery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "10");//用於分頁的變量
                query1 = _OrderDetailMgr.AllOrderDeliver(oddquery, out total, sq);

                //uint Normal_Subtotal = 0;//常溫商品總額--
                //uint Hypothermia_Subtotal = 0;//低溫商品總額---
                //uint All_Normal_Subtotal = 0;//當日常溫運費總額
                //uint All_Hypothermia_Subtotal = 0;//當日低溫運費總額
                //uint Order_Freight_Normal = 0;//常溫運費
                //uint Order_Freight_Low = 0;//低溫運費
                //uint All_Order_Freight_Normal = 0;//當日常溫運費--
                //uint All_Order_Freight_Low = 0;//當日低溫運費--


                foreach (var item in query1)
                {
                    if (item.item_mode == 1)
                        continue;
                    //商品總額計算(當下出貨金額與運費)
                    if (item.Product_Freight_Set == PRODUCT_FREIGHT_NORMAL || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_NORMAL)//常溫,常溫免運
                    {
                        if (item.item_mode == 2)
                        {

                            Normal_Subtotal += item.Single_Price * item.parent_num;
                            item.Buy_Num = item.Buy_Num * item.parent_num;
                            item.Single_Price = item.Single_Price * item.parent_num;

                            //Normal_Subtotal += item.Single_Price * item.parent_num;//---
                            //item.Buy_Num = item.Buy_Num * item.parent_num;//-------
                            //item.Single_Money = item.Single_Price * item.Buy_Num;//---------
                        }
                        else
                        {
                            Normal_Subtotal += item.Single_Price * item.Buy_Num;
                            item.Single_Money = item.Single_Price * item.Buy_Num;
                        }
                    }
                    else if (item.Product_Freight_Set == PRODUCT_FREIGHT_LOW || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_LOW)//低溫,低溫免運
                    {
                        if (item.item_mode == 2)
                        {
                            Hypothermia_Subtotal += item.Single_Price * item.parent_num;
                            item.Buy_Num = item.Buy_Num * item.parent_num;
                            item.Single_Price = item.Single_Price * item.parent_num;
                            //Hypothermia_Subtotal += item.Single_Price * item.parent_num;//--------
                            //item.Buy_Num = item.Buy_Num * item.parent_num;//------------
                            //item.Single_Money = item.Single_Price * item.Buy_Num;//---------
                        }
                        else
                        {
                            Hypothermia_Subtotal += item.Single_Price * item.Buy_Num;
                            item.Single_Money = item.Single_Price * item.Buy_Num;
                        }
                    }
                    query2.Add(item);
                }
                _VendorMgr = new VendorMgr(mySqlConnectionString);
                BLL.gigade.Model.Vendor vendor = new BLL.gigade.Model.Vendor();
                vendor.vendor_id = vendor_id;
                vendor = _VendorMgr.GetSingle(vendor);
                //當下運費計算
                if (Normal_Subtotal != 0)
                {
                    if (vendor.freight_normal_limit > Normal_Subtotal)
                    {
                        Order_Freight_Normal = vendor.freight_normal_money;
                    }
                }
                if (Hypothermia_Subtotal != 0)
                {
                    if (vendor.freight_low_limit > Hypothermia_Subtotal && Hypothermia_Subtotal > 0)
                    {
                        Order_Freight_Low = vendor.freight_low_money;
                    }
                }
                //批次單總額運費
                if (All_Normal_Subtotal != 0)
                {
                    if (vendor.freight_normal_limit > All_Normal_Subtotal)
                    {
                        All_Order_Freight_Normal = vendor.freight_normal_money;
                    }
                }
                if (All_Hypothermia_Subtotal != 0)
                {
                    if (vendor.freight_low_limit > All_Order_Freight_Low)
                    {
                        All_Order_Freight_Low = vendor.freight_low_money;
                    }
                }

                #endregion
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                json = "{success:true,Normal_Subtotal:" + Normal_Subtotal + ",Hypothermia_Subtotal:" + Hypothermia_Subtotal + ",Order_Freight_Normal:" + Order_Freight_Normal + ",Order_Freight_Low:" + Order_Freight_Low;
                json += ",All_Order_Freight_Normal:" + All_Order_Freight_Normal + ",All_Order_Freight_Low:" + All_Order_Freight_Low + ",data:" + JsonConvert.SerializeObject(query2, Formatting.Indented, timeConverter) + "}";//返回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:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Beispiel #24
0
        //chaojie天界與2015-07-09上面的用作供應商下拉列表,數據太多 可能導致延遲或數據加載不出
        public List<Vendor> VendorQueryList(Vendor query)
        {
            query.Replace4MySQL();
            StringBuilder sbSql = new StringBuilder();
            try
            {
                sbSql.Append(@" SELECT vendor_id,vendor_name_full,vendor_name_simple FROM vendor WHERE vendor_status = 1 ");
                if (query.assist != 0)
                {
                    sbSql.AppendFormat(" AND assist = 1 ");
                }

                sbSql.Append(" ORDER BY vendor_id ASC");
                return _dbAccess.getDataTableForObj<Vendor>(sbSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(" vendorDao-->VendorQueryList-->" + ex.Message + sbSql.ToString(), ex);
            }
        }
 public HttpResponseBase GetVendorName()
 {
     _IiplasMgr = new IplasMgr(mySqlConnectionString);
     List<Vendor> stores = new List<Vendor>();
     string json = string.Empty;
     try
     {
         Vendor query = new Vendor();
         string sql = string.Empty;
         if (!string.IsNullOrEmpty(Request.Params["type"]))
         {
             sql = "";
         }
         else
         {
             sql = " and assist = 1 ";
         }
         stores = _IiplasMgr.VendorQueryAll(query, sql);
         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;
 }
Beispiel #26
0
 public string InsertVendor(Vendor model)
 {
     model.Replace4MySQL();
     StringBuilder strSql = new StringBuilder();
     try
     {
         strSql.Append("insert into vendor( vendor_id,vendor_code,vendor_status,vendor_email,vendor_password,vendor_name_full,vendor_name_simple,vendor_invoice, ");
         strSql.Append("company_phone,company_fax,company_person,company_zip,company_address,invoice_zip,invoice_address,contact_type_1,contact_name_1,contact_phone_1_1,");
         strSql.Append("contact_phone_2_1,contact_mobile_1,contact_email_1,contact_type_2,contact_name_2,contact_phone_1_2,contact_phone_2_2,contact_mobile_2,contact_email_2,");
         strSql.Append("contact_type_3,contact_name_3,contact_phone_1_3,contact_phone_2_3,contact_mobile_3,contact_email_3,contact_type_4,contact_name_4,contact_phone_1_4,");
         strSql.Append("contact_phone_2_4,contact_mobile_4,contact_email_4,contact_type_5,contact_name_5,contact_phone_1_5,contact_phone_2_5,contact_mobile_5,contact_email_5,");
         strSql.Append("cost_percent,creditcard_1_percent,creditcard_3_percent,sales_limit,bonus_percent,agreement_createdate,agreement_start,agreement_end,checkout_type,");
         strSql.Append("checkout_other,bank_code,bank_name,bank_number,bank_account,freight_low_limit,freight_low_money,freight_normal_limit,freight_normal_money,");
         strSql.Append("freight_return_low_money,freight_return_normal_money,vendor_note,vendor_confirm_code,vendor_login_attempts,assist,dispatch,product_mode,");
         strSql.Append("product_manage,erp_id,gigade_bunus_percent,gigade_bunus_threshold, procurement_days,self_send_days,stuff_ware_days,dispatch_days,export_flag,vendor_type,kuser,kdate)");//vendor_type供應商類型
         strSql.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',",
             model.vendor_id, model.vendor_code, model.vendor_status, model.vendor_email, model.vendor_password, model.vendor_name_full, model.vendor_name_simple, model.vendor_invoice);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',",
             model.company_phone, model.company_fax, model.company_person, model.company_zip, model.company_address, model.invoice_zip, model.invoice_address, model.contact_type_1, model.contact_name_1, model.contact_phone_1_1);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',",
             model.contact_phone_2_1, model.contact_mobile_1, model.contact_email_1, model.contact_type_2, model.contact_name_2, model.contact_phone_1_2, model.contact_phone_2_2, model.contact_mobile_2, model.contact_email_2);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',",
             model.contact_type_3, model.contact_name_3, model.contact_phone_1_3, model.contact_phone_2_3, model.contact_mobile_3, model.contact_email_3, model.contact_type_4, model.contact_name_4, model.contact_phone_1_4);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',",
             model.contact_phone_2_4, model.contact_mobile_4, model.contact_email_4, model.contact_type_5, model.contact_name_5, model.contact_phone_1_5, model.contact_phone_2_5, model.contact_mobile_5, model.contact_email_5);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',",
              model.cost_percent, model.creditcard_1_percent, model.creditcard_3_percent, model.sales_limit, model.bonus_percent, model.agreement_createdate, model.agreement_start, model.agreement_end, model.checkout_type);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',",
             model.checkout_other, model.bank_code, model.bank_name, model.bank_number, model.bank_account, model.freight_low_limit, model.freight_low_money, model.freight_normal_limit, model.freight_normal_money);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',",
             model.freight_return_low_money, model.freight_return_normal_money, model.vendor_note, model.vendor_confirm_code, model.vendor_login_attempts, model.assist, model.dispatch, model.product_mode);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}',", model.product_manage, model.erp_id, model.gigade_bunus_percent, model.gigade_bunus_threshold);
         strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}');", model.procurement_days, model.self_send_days, model.stuff_ware_days, model.dispatch_days, model.export_flag, model.vendor_type, model.kuser, CommonFunction.DateTimeToString(model.kdate));
         return strSql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception(" vendorDao-->InsertVendor-->" + ex.Message + strSql.ToString(), ex);
     }
 }
Beispiel #27
0
        //public List<ProductQueryForExcel> NoIlocReportList(ProductQuery query, out int totalCount) 
        //{
        //    try
        //    {
        //        return _IplasDao.NoIlocReportList(query,out totalCount);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception("IplasMgr-->NOIlocReportList-->" + ex.Message, ex);
        //    }
        //}

       public List<Vendor> VendorQueryAll(Vendor query, string AddSql = null)
        {
            try
            {
                return _IplasDao.VendorQueryAll(query, AddSql);
            }
            catch (Exception ex)
            {
                throw new Exception("IplasMgr-->GetIlocReportList-->" + ex.Message, ex);
            }
        }