/// <summary> /// 顯示修改區塊 /// </summary> protected void setEditView() { try { P_list.Visible = false; P_add.Visible = false; P_edit.Visible = true; var logistics = new POS_Library.ShopPos.LogisticsAccount(); LDList = logistics.GetLogisticsDetail(id); //只有一筆 if (LDList.Count == 1) { lbl_ID.Text = LDList.First().Id.ToString(); lbl_barcode.Text = LDList.First().Barcode; txt_EditAccount.Text = LDList.First().Account; } else { Response.Redirect("~/logistics_account.aspx"); } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 刪除帳號(2012-0528新增) /// </summary> protected void delete_account() { try { var logistics = new POS_Library.ShopPos.LogisticsAccount(); Result = logistics.SetDelLogistics(id); switch (Result) { case true: //成功 Page.RegisterClientScriptBlock("checkinput", @"<script>alert('刪除 成功!');window.close();</script>"); break; case false: //失敗 Page.RegisterClientScriptBlock("checkinput", @"<script>alert('刪除 失敗!');window.close();</script>"); break; default: break; } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 新增帳號 /// </summary> protected void AddSubmit() { try { //lbl_AddMessage.Text = ""; if (txt_AddAccount.Text != "") { var logistics = new POS_Library.ShopPos.LogisticsAccount(); var MSList = logistics.SetLogistics(txt_AddAccount.Text, zone); if (MSList.Result == "1") { //Response.Write("<script>alert('新增成功!');location.href='logistics_account.aspx';</script>"); Page.RegisterClientScriptBlock("checkinput", @"<script>alert('新增成功!');location.href='logistics_account.aspx';</script>"); } else { //Response.Write("<script>alert('此帳號已存在,新增失敗!');</script>"); Page.RegisterClientScriptBlock("checkinput", @"<script>alert('失敗! " + MSList.Reason + "');location.href='logistics_account.aspx';</script>"); } } else { //Response.Write("<script>alert('帳號不可為空');location.href='logistics_account.aspx?act=add&zone=1';</script>"); Page.RegisterClientScriptBlock("checkinput", @"<script>alert('帳號不可為空');location.href='logistics_account.aspx?act=add&zone=" + zone + "';</script>"); //lbl_AddMessage.Text = "帳號不可為空"; } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 設定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Send_Click(object sender, EventArgs e) { if (gv_logistics.Rows.Count == 0) { return; } string fail = ""; foreach (GridViewRow iRow in gv_logistics.Rows) { TextBox tb = (TextBox)iRow.FindControl("txtScore"); var newScore = decimal.Parse(tb.Text); if (decimal.Parse(iRow.Cells[1].Text) != newScore) { var job = new POS_Library.ShopPos.LogisticsAccount(); var setting = job.SetLogisticsSetting(iRow.Cells[0].Text, newScore); if (!setting) { fail += iRow.Cells[0].Text + ","; } } } DefaultLoad(); lbl_Msg.Text = (string.IsNullOrEmpty(fail)) ? " 設定成功!" : fail + " 設定失敗! "; }
/// <summary> /// 讀取名單 /// </summary> protected void LoadLogisticsList() { try { dt.Clear(); var logistics = new POS_Library.ShopPos.LogisticsAccount(); try { if (zone != null) { LDList = logistics.GetLoadLogistics(zone); } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } #region ●有特定帳號的話過濾(2014-0115新增) //有特定帳號的話過濾------------------------ var SearchName = txt_Name.Text.Trim(); if (!string.IsNullOrEmpty(SearchName)) { LDList = LDList.Where(x => x.Account.Contains(SearchName)).ToList(); } #endregion //List資料丟進datatable內 if (LDList.Count > 0) { for (int i = 0; i < LDList.Count; i++) { DataRow dr = dt.NewRow(); dr["ID"] = LDList[i].Id; dr["條碼"] = LDList[i].Barcode; dr["帳號"] = LDList[i].Account; dt.Rows.Add(dr); } } ViewState["dt"] = dt; gv_Account.DataSource = dt; gv_Account.DataBind(); var 總筆數 = LDList.Count; lbl_Count.Text = "總筆數:" + 總筆數; } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 查詢 /// </summary> protected void DefaultLoad() { var job = new POS_Library.ShopPos.LogisticsAccount(); var setting = job.GetLogisticsSetting().Select(x => new { Name = x.GroupName, oldScore = x.Score, newScore = x.Score }).Distinct().ToList(); gv_logistics.DataSource = setting; gv_logistics.DataBind(); }
/// <summary> /// 修改帳號 /// </summary> protected void EditSubmit() { try { //lbl_EditMessage.Text = ""; if (Session["EditAccount"] != null) { txt_EditAccount.Text = Session["EditAccount"].ToString(); } if (txt_EditAccount.Text != "") { var logistics = new POS_Library.ShopPos.LogisticsAccount(); var MSList = logistics.UpdateLogistics(lbl_ID.Text, txt_EditAccount.Text); if (MSList.Result == "1") { //Response.Write("<script>alert('修改成功!');location.href='logistics_account.aspx';</script>"); Page.RegisterClientScriptBlock("checkinput", @"<script>alert('修改成功!');location.href='logistics_account.aspx';</script>"); Session["EditAccount"] = null; } else { //Response.Write("<script>alert('此帳號已存在,修改失敗!');</script>"); Page.RegisterClientScriptBlock("checkinput", @"<script>alert('失敗! " + MSList.Reason + "');</script>"); } } else { //Response.Write("<script>alert('帳號不可為空');location.href='logistics_account.aspx?act=edit&id=" + lbl_ID.Text + "';</script>"); Page.RegisterClientScriptBlock("checkinput", @"<script>alert('帳號不可為空');location.href='logistics_account.aspx?act=edit&id=" + lbl_ID.Text + "';</script>"); //lbl_AddMessage.Text = "帳號不可為空"; } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 產生報表 /// </summary> protected void SearchPrint() { try { //使用服務查詢 var job = new POS_Library.ShopPos.LogisticsAccount(); if (DDL_Type.SelectedValue == "1+") { LRList = job.GetPrintLogisticsForPick(zone, txt_Start.Text + time1, txt_End.Text + time2); if (LRList.Count > 0) { var aa = (from i in LRList orderby i.Account, i.Group select new { 帳號 = i.Account, 種類 = ((POS_Library.Public.Utility.LogisticsType) int.Parse(i.TypeName)).ToString(), 區域 = i.Group, 項目 = i.ProductItem, 件數 = i.ProductQuantity, 分數 = decimal.Round(i.ProductScore, 2, MidpointRounding.AwayFromZero) }).ToList(); if (CB_Sort.Checked) { aa = aa.OrderBy(x => x.區域).ToList(); } gv_logistics.DataSource = aa; var 總分數 = aa.Select(x => x.分數).Sum(); var 總筆數 = aa.Count; lbl_Count.Text = "總筆數:" + 總筆數 + ", 總分數:" + 總分數; } } else { LRList = job.GetPrintLogistics(zone, txt_Start.Text + time1, txt_End.Text + time2); if (LRList.Count > 0) { var aa = (from i in LRList where (DDL_Type.SelectedIndex == 0) ? true : ((DDL_Type.SelectedValue == "3") ? (i.TypeName == DDL_Type.SelectedValue || i.TypeName == "103") : i.TypeName == DDL_Type.SelectedValue) orderby int.Parse(i.TypeName), i.ProductScore descending select new { 帳號 = i.Account, 種類 = ((POS_Library.Public.Utility.LogisticsType) int.Parse(i.TypeName)).ToString(), 項目 = i.ProductItem, 件數 = i.ProductQuantity, 分數 = decimal.Round(i.ProductScore, 2, MidpointRounding.AwayFromZero) }).ToList(); gv_logistics.DataSource = aa; var 總分數 = decimal.Round(aa.Select(x => x.分數).Sum(), 2, MidpointRounding.AwayFromZero); var 總筆數 = aa.Count; lbl_Count.Text = "總筆數:" + 總筆數 + ", 總分數:" + 總分數; } } gv_logistics.DataBind(); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 產生barcode PDF /// </summary> protected void BarcodePDF() { try { var logistics = new POS_Library.ShopPos.LogisticsAccount(); LDList = logistics.GetLogisticsDetail(id); var LBList = logistics.GetBarcode(id); //if有找到資料 if (LDList.Count > 0) { //宣告文件doc1 Document doc1 = new Document(PageSize.A4, 20, 20, 40, 20); MemoryStream Memory = new MemoryStream(); PdfWriter PdfWriter = PdfWriter.GetInstance(doc1, Memory); //建立中文字型 BaseFont bfChinese = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\mingliu.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //開始編輯doc1 doc1.Open(); //取得內容物件DirectContent PdfContentByte PCB = PdfWriter.DirectContent; //啟用PCB PCB.SaveState(); PCB.BeginText(); PCB.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL); PCB.SetFontAndSize(bfChinese, 14); float offset_xi = 50, offset_yi = 800; for (int i = 0; i < 10; i++) { switch (i) { case 0: offset_xi = 60; offset_yi = 770; break; case 1: offset_xi = 285; offset_yi = 770; break; case 2: offset_xi = 60; offset_yi = 630; break; case 3: offset_xi = 285; offset_yi = 630; break; case 4: offset_xi = 60; offset_yi = 490; break; case 5: offset_xi = 285; offset_yi = 490; break; case 6: offset_xi = 60; offset_yi = 350; break; case 7: offset_xi = 285; offset_yi = 350; break; case 8: offset_xi = 60; offset_yi = 210; break; case 9: offset_xi = 285; offset_yi = 210; break; } //設定帳號及圖片位置 PCB.ShowTextAligned(0, LDList[0].Account, offset_xi, offset_yi, 0); iTextSharp.text.Image img; img = iTextSharp.text.Image.GetInstance(LBList[0].ImageSource); img.ScalePercent(80, 40); img.SetAbsolutePosition(offset_xi - 35, offset_yi - 70); PCB.AddImage(img); } PCB.EndText(); //畫格線 PCB.SetRGBColorFill(0x00, 0x00, 0x00); //上下兩條橫線 PCB.Rectangle(30, 810, 450, 1); PCB.Fill(); PCB.Rectangle(30, 109, 450, 1); PCB.Fill(); //三條垂直線 PCB.Rectangle(30, 110, 1, 700); PCB.Fill(); PCB.Rectangle(480, 109, 1, 702); PCB.Fill(); PCB.Rectangle(255, 110, 1, 701); PCB.Fill(); //中間四條橫線 PCB.Rectangle(30, 249, 450, 1); PCB.Fill(); PCB.Rectangle(30, 389, 450, 1); PCB.Fill(); PCB.Rectangle(30, 529, 450, 1); PCB.Fill(); PCB.Rectangle(30, 669, 450, 1); PCB.Fill(); //關閉PCB //PCB.EndText(); PCB.RestoreState(); doc1.Close(); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=logistics_account_barcode_" + id + ".pdf"); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(Memory.GetBuffer(), 0, Memory.GetBuffer().Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.Flush(); Response.End(); } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 產生報表 /// </summary> protected void SearchPrint() { try { try { //使用服務查詢 var job = new POS_Library.ShopPos.LogisticsAccount(); LPList = job.GetPrintLogistics(zone, txt_Start.Text, DateTime.Parse(txt_End.Text).AddDays(1).ToString("yyyy-MM-dd")); } catch (Exception ex) { string a = POS_Library.Public.Utility.Stack.ExceptionMsg(ex); Response.Write("系統發生錯誤 " + a); } if (LPList.Count > 0) { for (int i = 0; i < LPList.Count; i++) { DataRow dr = dt.NewRow(); dr["帳號"] = LPList[i].Account; //暫存帳號 String Account = ""; decimal score = 0; int j = i + 1; var logistics = new List <string>(); logistics.Add(((int)POS_Library.Public.Utility.LogisticsType.入庫確認).ToString()); logistics.Add(((int)POS_Library.Public.Utility.LogisticsType.入庫上架).ToString()); logistics.Add(((int)POS_Library.Public.Utility.LogisticsType.移動儲位).ToString()); logistics.Add(((int)POS_Library.Public.Utility.LogisticsType.調出驗貨確認).ToString()); logistics.Add(((int)POS_Library.Public.Utility.LogisticsType.盤點無條件上架).ToString()); logistics.Add(((int)POS_Library.Public.Utility.LogisticsType.盤點無條件打銷).ToString()); if (Account == "") { Account = LPList[i].Account; score += (!logistics.Contains(LPList[i].TypeName)) ? LPList[i].ProductScore : LPList[i].ProductQuantity; } //帳號相同時把分數加總 while (j < LPList.Count && Account == LPList[j].Account) { score += (!logistics.Contains(LPList[i].TypeName)) ? LPList[j].ProductScore : LPList[j].ProductQuantity; j++; } //加總完放入 dr["總分"] = score.ToString(); Account = ""; score = 0; j = i; dr["種類"] = ((POS_Library.Public.Utility.LogisticsType) int.Parse(LPList[i].TypeName)).ToString(); dr["項目"] = LPList[i].ProductItem; dr["件數"] = LPList[i].ProductQuantity; dr["分數"] = (!logistics.Contains(LPList[i].TypeName)) ? LPList[i].ProductScore : LPList[i].ProductQuantity; dt.Rows.Add(dr); } } gv_logistics.DataSource = dt; gv_logistics.DataBind(); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 登入 /// </summary> protected void Login() { try { if (txt_ID.Text.Trim() == "guest") { String ID = txt_ID.Text = txt_ID.Text.Trim().ToLower(); Session["Account"] = "Guest"; Session["Name"] = "Guest"; //取client ip Session["ip"] = Request.Cookies["myip"].Value; Cookie(ID); //加入onlineList帳號(2013-1106新增)----- AddOnlineList(ID); Response.Redirect("~/index.aspx"); } //帳密登入 else if (txt_ID.Text.Trim() != "" && txt_PW.Text.Trim() != "") { //0b389280842de54c String ID = txt_ID.Text = txt_ID.Text.Trim().ToLower(); String PW = txt_PW.Text.Trim(); EntranceService.Result Lg = new Result(); ADVerifyService.ADVerifyClient ADVC = new ADVerifyService.ADVerifyClient(); ADVerifyService.Identity ADI = ADVC.Verify("OBDesign.com.tw", txt_ID.Text, txt_PW.Text); try { Lg = EC.LogIn(ID, PW); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } if (Lg.ResultStatus == ResultType.Success) { String account = Lg.Account; Session["ID"] = ID; Session["PW"] = PW; Session["Account"] = account; //取得中文名(如果AD有) Session["Name"] = string.IsNullOrEmpty(Lg.Fullname) ? Lg.Account : Lg.Fullname; Session["Zone"] = "1"; Session["ShipOutType"] = (Utility.Area)_areaId; Session["EID"] = ADI.EmployeeID; //取client ip //正式cookieIP(2012-1205新增) Session["ip"] = Request.Cookies["myip"].Value; //正式 //Session["ip"] = HttpContext.Current.Request.UserHostAddress; //測試 //Session["ip"] = Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString(); //權限設定(2012-0110 舊權限確認方式) //auth.check(account); //(2012-0110 新權限確認方式) auth.setAuthority(Lg.Authoritys); //(2014-0509 新新權限確認方式) auth.setAuthorityPro(ID, 1); var test = auth.checkAuthorityPro("4"); Cookie(ID); //加入onlineList帳號(2013-1106新增)----- AddOnlineList(ID); if (urlx != null && urlx != "") { Response.Redirect("~/" + urlx); } else { Response.Redirect("~/index.aspx"); } } else { lbl_Message.Text = "登入失敗"; } } //密碼為空則使用物流BarCode登入 else if (txt_ID.Text.Trim() != "" && txt_PW.Text.Trim() == "") { //List<EntranceService.StructLogin> Lg = new List<StructLogin>(); String ID = txt_ID.Text = txt_ID.Text.Trim(); #region ●service登入(舊) //EntranceService.Result Lg = new Result(); //try //{ // Lg = EC.EmployeeCode(ID); //} //catch (Exception ex) //{ // Response.Write("系統發生錯誤 " + ex.Message); //} //if (Lg.ResultStatus == ResultType.Success && Lg.Zone == "1") //{ // String account = Lg.Account; // String zone = Lg.Zone; // Session["Account"] = account; // //取得中文名(如果AD有) // Session["Name"] = string.IsNullOrEmpty(Lg.Fullname) ? Lg.Account : Lg.Fullname; // Session["logisticAccount"] = true; // Session["Zone"] = zone; // Session["ShipOutType"] = "橘熊"; // //取client ip // //正式cookieIP(2012-1205新增) // Session["ip"] = Request.Cookies["myip"].Value; // //正式 // //Session["ip"] = HttpContext.Current.Request.UserHostAddress; // //測試 // //Session["ip"] = Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString(); // //權限設定(2012-0110 舊權限確認方式) // //auth.check(account); // //若有權限則設定(2012-0110 新權限確認方式) // if (Lg.Authoritys != null) // auth.setAuthority(Lg.Authoritys); // //(2014-0509 新新權限確認方式) // auth.setAuthorityPro(ID, 0); // var test = auth.checkAuthorityPro("4"); // Cookie(ID); // //加入onlineList帳號(2013-1106新增)----- // AddOnlineList(ID); // if (urlx != null && urlx != "") // Response.Redirect("~/" + urlx); // else // Response.Redirect("~/index.aspx"); //} //else //{ // lbl_Message.Text = "登入失敗"; //} #endregion #region ●門市client server DB登入 POS_Library.ShopPos.LogisticsAccount LG = new POS_Library.ShopPos.LogisticsAccount(); var ResultStatus = LG.GetLogisticsDetailByBarcode(ID); if (ResultStatus.Count == 1) { String account = ResultStatus[0].Account; String zone = ResultStatus[0].Zone.ToString(); Session["Account"] = account; Session["ClerkID"] = ResultStatus[0].Id; //取得中文名(如果AD有) Session["Name"] = account; Session["logisticAccount"] = true; Session["Zone"] = zone; Session["ShipOutType"] = (Utility.Area) int.Parse(zone); //取client ip //正式cookieIP(2012-1205新增) Session["ip"] = Request.Cookies["myip"].Value; //正式 //Session["ip"] = HttpContext.Current.Request.UserHostAddress; //測試 //Session["ip"] = Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString(); //權限設定(2012-0110 舊權限確認方式) //auth.check(account); //若有權限則設定(2012-0110 新權限確認方式) //if (Lg.Authoritys != null) // auth.setAuthority(Lg.Authoritys); //(2014-0509 新新權限確認方式) auth.setAuthorityPro(ID, 0); var test = auth.checkAuthorityPro("4"); Cookie(ID); //加入onlineList帳號(2013-1106新增)----- AddOnlineList(ID); //if (urlx != null && urlx != "") // Response.Redirect("~/" + urlx); //else // Response.Redirect("~/index.aspx"); Response.Redirect("~/pos_check_out.aspx"); } else { lbl_Message.Text = "登入失敗"; } #endregion } else { lbl_Message.Text = "帳號為空白"; } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }