protected void Page_Load(object sender, EventArgs e) { context = new SaalutDataClasses1DataContext(); if (Request.QueryString["ID"] == null) { Response.Redirect("~/NewJours.aspx"); } Int32.TryParse(Request.QueryString["ID"], out jourID); if (jourID == 0) { Response.Redirect("~/NewJours.aspx"); } NewJourLineLinqDataSource1.WhereParameters[0].DefaultValue = jourID.ToString(); NewJourLineLinqDataSource1.DataBind(); if (!IsPostBack) { if (Session["JourCart"] == null) { Session["JourCart"] = new JourCart(); } if (Session["PrintTemplateCart"] == null) { Session["PrintTemplateCart"] = new PrintTemplateCart(); } } var jour = (from j in context.PriceChangeJours where j.ID == jourID select j).FirstOrDefault(); if (jour == null) { Response.Redirect("~/Default.aspx"); } if (jour.Order_no != 0) { JournalNumLabel1.Text = "Журнал УКМ N: " + jour.Order_no.ToString(); } else { JournalNumLabel1.Text = "Журнал УКМ N: " + jour.ID.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { if (context == null) { context = new SaalutDataClasses1DataContext(); } if (!IsPostBack) { Session["JourCart"] = new JourCart(); Session["PrintTemplateCart"] = new PrintTemplateCart(); } }
protected void AddToCart(int jourLineID) { JourCart cart = (JourCart)Session["JourCart"]; int i = 0; Boolean inCart = false; foreach (JourCartItem items in cart) { if (items.JourLineID == jourLineID) { cart.RemoveAt(i); inCart = true; break; } i++; } if (!inCart) { JourCartItem item = new JourCartItem(jourLineID); cart.Add(item); } }
protected void NewJourLinesGridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PriceChangeLine row = (PriceChangeLine)e.Row.DataItem; int LineID = (int)DataBinder.Eval(e.Row.DataItem, "ID"); string ItemID_UKM = (string)DataBinder.Eval(e.Row.DataItem, "ItemID_UKM"); TextBox ProizvoditelTextBox1 = (TextBox)e.Row.FindControl("ProizvoditelTextBox1"); TextBox GoodNameTextBox1 = (TextBox)e.Row.FindControl("GoodNameTextBox1"); var good = (from g in context.Goods where g.Articul == ItemID_UKM select g).FirstOrDefault(); // set def value if (GoodNameTextBox1.Text == "") { GoodNameTextBox1.Text = good.Descr; } if (ProizvoditelTextBox1.Text == "") { ProizvoditelTextBox1.Text = good.Country; } LinkButton SelectLinkButton1 = (LinkButton)e.Row.FindControl("SelectLinkButton1"); if (Session["JourCart"] != null) { JourCart cart = (JourCart)Session["JourCart"]; foreach (JourCartItem items in cart) { if (items.JourLineID == LineID) { SelectLinkButton1.Text = "Исключить"; e.Row.Style.Add(HtmlTextWriterStyle.BackgroundColor, "LightGrey"); break; } } } // шаблон ценников DropDownList PrintTemplateDropDownList1 = (DropDownList)e.Row.FindControl("PrintTemplateDropDownList1"); //int oldTemplateID = 0; //Int32.TryParse(PrintTemplateDropDownList1.SelectedValue, out oldTemplateID); var printTempls = from t in context.PrintTemplates select t; PrintTemplateDropDownList1.DataSource = printTempls; int templateIDInCart = 0; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem item in templCart) { if (item.JourLineID == LineID) { templateIDInCart = item.TemplateID; //if (item.Proizvoditel != ProizvoditelTextBox1.Text) // ProizvoditelTextBox1.Text = item.Proizvoditel; //if (item.GoodName != GoodNameTextBox1.Text) // GoodNameTextBox1.Text = item.GoodName; break; } } if (templateIDInCart == 0) { if (good != null) { if (good.PrintTemplateID != null) { templateIDInCart = good.PrintTemplateID.Value; } else { // ищем шаблон на верхнем уровне. int printTemplGroupId = 0; int upGroupID = 0; if (good.Group.GroupRangeID != 0 && good.Group.GroupRangeID != null) { upGroupID = good.Group.GroupRangeID.Value; } while (upGroupID != 0) { var grp = (from g in context.Groups where g.ID == upGroupID select g).FirstOrDefault(); if (grp == null) { continue; } if (grp.PrintTemplateID == null) { if (grp.GroupRangeID != 0 && grp.GroupRangeID != null) { upGroupID = grp.GroupRangeID.Value; continue; } else { upGroupID = 0; } } else { printTemplGroupId = grp.PrintTemplateID.Value; break; } if (good.Group.GroupRangeID != 0 && good.Group.GroupRangeID != null) { upGroupID = good.Group.GroupRangeID.Value; } if (grp.GroupRangeID == null) { break; } } if (printTemplGroupId != 0) { templateIDInCart = printTemplGroupId; } else { templateIDInCart = printTempls.FirstOrDefault().ID; } } } else { templateIDInCart = printTempls.FirstOrDefault().ID; } } PrintTemplateDropDownList1.SelectedValue = templateIDInCart.ToString(); PrintTemplateDropDownList1.DataBind(); //- конец шаблоны ценников AddToCartTemplate(LineID, templateIDInCart, ProizvoditelTextBox1.Text, GoodNameTextBox1.Text); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Dictionary <int, int> groupTemlates = new Dictionary <int, int>(); context = new SaalutDataClasses1DataContext(); if (Request.QueryString["ID"] == null) { //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); Response.Redirect("ByFind.aspx"); } Int32.TryParse(Request.QueryString["ID"], out jourID); if (jourID == 0) { //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); Response.Redirect("ByFind.aspx"); } if (Request.QueryString["WP"] != null) { int tmpI = 0; Int32.TryParse(Request.QueryString["WP"], out jourID); if (tmpI == 1) { WhithoutPrice = true; } } if (Request.QueryString["q"] != null) { Int32.TryParse(Request.QueryString["q"], out qty); } if (Request.QueryString["f"] != null) { Int32.TryParse(Request.QueryString["f"], out termPrinterID); } //if (Session["JourCart"] == null) // //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); // Response.Redirect("NewJours.aspx"); if (termPrinterID == 0) { // Ищем термо ценник для печати на принтере var termCennic = (from c in context.ThermoLabels where c.FileLabelName.EndsWith(".slb") select c).FirstOrDefault(); if (termCennic == null) { Response.Redirect("ByFind.aspx"); } var termPrnt = (from t in context.TermoPrinters where t.TermoPrinterPort == "lpt4" select t).FirstOrDefault(); if (termPrnt == null) { Response.Redirect("ByFind.aspx"); } string dateForLabel = DateTime.Today.ToString("d"); var jLines = from j in context.PriceChangeLine where j.JournalID == jourID select j; foreach (PriceChangeLine ln in jLines) { if (WhithoutPrice == true) { var prs = (from p in context.Prices where p.GoodID == ln.GoodID && p.Active == true select p).FirstOrDefault(); if (prs == null) { continue; } } TermLabelUtils utl = new TermLabelUtils(); JourCart cart = (JourCart)Session["JourCart"]; foreach (JourCartItem items in cart) { if (items.JourLineID == ln.ID) { string proizvoditel = ""; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem itemTempl in templCart) { if (itemTempl.JourLineID == ln.ID) { proizvoditel = itemTempl.Proizvoditel; break; } } // входит в список распечатки. int n = 0; while (n < qty) { utl.PrintTermoCennic(ln.GoodID.Value, termCennic.ID, 1, termPrnt.ID, dateForLabel, proizvoditel); n++; } break; } } } } else // большой ценник { // Ищем термо ценник для печати на принтере var termCennic2 = (from c in context.ThermoLabels where c.FileLabelName.EndsWith(".blb") && c.Active == true select c).FirstOrDefault(); var termCennic1 = (from c in context.ThermoLabels where c.FileLabelName.EndsWith(".slb") && c.Active == true select c).FirstOrDefault(); var termPrnt = (from t in context.TermoPrinters where t.ID == termPrinterID && t.Active == true select t).FirstOrDefault(); if (termPrnt == null) { Response.Redirect("ByFind.aspx"); } string dateForLabel = DateTime.Today.ToString("d"); var jLines = from j in context.PriceChangeLine where j.JournalID == jourID select j; foreach (PriceChangeLine ln in jLines) { if (WhithoutPrice == true) { var prs = (from p in context.Prices where p.GoodID == ln.GoodID && p.Active == true select p).FirstOrDefault(); if (prs == null) { continue; } } TermLabelUtils utl = new TermLabelUtils(); JourCart cart = (JourCart)Session["JourCart"]; foreach (JourCartItem items in cart) { if (items.JourLineID == ln.ID) { string proizvoditel = ""; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem itemTempl in templCart) { if (itemTempl.JourLineID == ln.ID) { proizvoditel = itemTempl.Proizvoditel; break; } } // входит в список распечатки. int n = 0; while (n < qty) { if (termPrnt.TermoPrinterPort == "lpt4") { utl.PrintTermoCennic(ln.GoodID.Value, termCennic1.ID, 1, termPrinterID, dateForLabel, proizvoditel); } else if (termPrnt.TermoPrinterPort == "lpt8") { utl.PrintTermoCennic(ln.GoodID.Value, termCennic2.ID, 1, termPrinterID, dateForLabel, proizvoditel); } n++; } break; } } } } // большой ценник } }
protected void Page_Load_old(object sender, EventArgs e) { if (!IsPostBack) { Dictionary <int, int> groupTemlates = new Dictionary <int, int>(); context = new SaalutDataClasses1DataContext(); if (Request.QueryString["ID"] == null) { //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); Response.Redirect("NewJours.aspx"); } Int32.TryParse(Request.QueryString["ID"], out jourID); if (jourID == 0) { //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); Response.Redirect("NewJours.aspx"); } if (Request.QueryString["WP"] != null) { int tmpI = 0; Int32.TryParse(Request.QueryString["WP"], out tmpI); if (tmpI == 1) { WhithoutPrice = true; } } //if (Session["JourCart"] == null) // //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); // Response.Redirect("NewJours.aspx"); var jLines = from j in context.PriceChangeLine where j.JournalID == jourID select j; foreach (PriceChangeLine ln in jLines) { if (WhithoutPrice == true) { var prs = (from p in context.Prices where p.GoodID == ln.GoodID && p.Active == true select p).FirstOrDefault(); if (prs == null) { continue; } } JourCart cart = (JourCart)Session["JourCart"]; foreach (JourCartItem items in cart) { if (items.JourLineID == ln.ID) { // входит в список распечатки. groupTemlates.Add(ln.ID, FindTemplate(ln.ID)); break; } } } // Выбираем данные из УКМ по ценам и сохраняем их в таблицу var store = (from s in context.StoreInfos where s.Active == true select s).FirstOrDefault(); if (store == null) { return; } //------ // выводим на экран с группировкой по типу ценника int currCountCennic = 0; foreach (var item in groupTemlates.OrderBy(key => key.Value)) { int templateIDInCart = 0; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem itemTempl in templCart) { if (itemTempl.JourLineID == item.Key) { templateIDInCart = itemTempl.TemplateID; break; } } Image img = new Image(); if (templateIDInCart == 0) { img.ImageUrl = "Services/Cennic.ashx?LID=" + item.Key.ToString() + "&TID=" + item.Value.ToString(); } else { img.ImageUrl = "Services/Cennic.ashx?LID=" + item.Key.ToString() + "&TID=" + templateIDInCart.ToString(); } CennicPlaceHolder1.Controls.Add(img); currCountCennic++; } currCountCennic = 0; if (groupTemlates.Count == 0) { var lines = from l in context.PriceChangeLine where l.JournalID == jourID && l.Active == true select l; foreach (PriceChangeLine line in lines) { if (WhithoutPrice == true) { var prs = (from p in context.Prices where p.GoodID == line.GoodID && p.Active == true select p).FirstOrDefault(); if (prs == null) { continue; } } int templateIDInCart = 0; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem itemTempl in templCart) { if (itemTempl.JourLineID == line.GoodID) { templateIDInCart = itemTempl.TemplateID; break; } } Image img = new Image(); img.ImageUrl = "Services/Cennic.ashx?LID=" + line.ID.ToString() + "&TID=" + templateIDInCart.ToString(); CennicPlaceHolder1.Controls.Add(img); currCountCennic++; } } } }
protected void Page_Load(object sender, EventArgs e) { string Division = WebConfigurationManager.AppSettings["Division"]; if (!IsPostBack) { Dictionary <int, int> groupTemlates = new Dictionary <int, int>(); context = new SaalutDataClasses1DataContext(); if (Request.QueryString["ID"] == null) { //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); Response.Redirect("NewJours.aspx"); } Int32.TryParse(Request.QueryString["ID"], out jourID); if (jourID == 0) { //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); Response.Redirect("NewJours.aspx"); } if (Request.QueryString["WP"] != null) { int tmpI = 0; Int32.TryParse(Request.QueryString["WP"], out tmpI); if (tmpI == 1) { WhithoutPrice = true; } } var store = (from s in context.StoreInfos where s.Active == true select s).FirstOrDefault(); if (store == null) { Response.Redirect("NewJours.aspx"); } //if (Session["JourCart"] == null) // //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true); // Response.Redirect("NewJours.aspx"); var jLines = from j in context.PriceChangeLine where j.JournalID == jourID select j; foreach (PriceChangeLine ln in jLines) { if (WhithoutPrice == true) { //var prs = (from p in context.Prices // where p.GoodID == ln.GoodID // && p.Active == true // select p).FirstOrDefault(); //if (prs == null) // continue; decimal price = 0; MySqlConnection cnx = null; try { DataTable prices; cnx = new MySqlConnection(connStr); MySqlDataAdapter adapter = new MySqlDataAdapter(); // Prices string cmdText = "select item, price, version, deleted from ukmserver.trm_in_pricelist_items where pricelist_id = '"+ store.PriceList_ID_UKM.ToString() + "' and item = '" + ln.Good.Articul.ToString() + "' and deleted = 0 "; MySqlCommand cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds5 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds5); prices = ds5.Tables[0]; if (prices != null) { // select item, price, version, deleted from ukmserver.trm_in_pricelist_items where pricelist_id = '" + store.PriceList_ID_UKM.ToString() + "' and deleted = 0 DataRow[] prsLsts = prices.Select("item = '" + ln.Good.Articul + "'"); foreach (DataRow row in prsLsts) { price = (decimal)row[1]; } } } catch (MySqlException ex) { Response.Redirect("ErrorPage.aspx"); } finally { if (cnx != null) { cnx.Close(); } } if (price == 0) { continue; } } // if (WhithoutPrice == true) JourCart cart = (JourCart)Session["JourCart"]; foreach (JourCartItem items in cart) { if (items.JourLineID == ln.ID) { // входит в список распечатки. groupTemlates.Add(ln.ID, FindTemplate(ln.ID)); break; } } } //------ // выводим на экран с группировкой по типу ценника int currCountCennic = 0; foreach (var item in groupTemlates.OrderBy(key => key.Value)) { string proizvoditel = ""; string goodName = ""; int templateIDInCart = 0; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem itemTempl in templCart) { if (itemTempl.JourLineID == item.Key) { templateIDInCart = itemTempl.TemplateID; proizvoditel = itemTempl.Proizvoditel; goodName = itemTempl.GoodName; break; } } Image img = new Image(); if (templateIDInCart == 0) { img.ImageUrl = "Services/Cennic.ashx?LID=" + item.Key.ToString() + "&TID=" + item.Value.ToString() + "&PID=" + Server.UrlEncode(proizvoditel) + "&GNID=" + Server.UrlEncode(goodName); } else { img.ImageUrl = "Services/Cennic.ashx?LID=" + item.Key.ToString() + "&TID=" + templateIDInCart.ToString() + "&PID=" + Server.UrlEncode(proizvoditel) + "&GNID=" + Server.UrlEncode(goodName); } CennicPlaceHolder1.Controls.Add(img); currCountCennic++; } currCountCennic = 0; if (groupTemlates.Count == 0) { var lines = from l in context.PriceChangeLine where l.JournalID == jourID && l.Active == true select l; foreach (PriceChangeLine line in lines) { if (WhithoutPrice == true) { //var prs = (from p in context.Prices // where p.GoodID == ln.GoodID // && p.Active == true // select p).FirstOrDefault(); //if (prs == null) // continue; decimal price = 0; MySqlConnection cnx = null; try { DataTable prices; cnx = new MySqlConnection(connStr); MySqlDataAdapter adapter = new MySqlDataAdapter(); // Prices string cmdText = "select item, price, version, deleted from ukmserver.trm_in_pricelist_items where pricelist_id = '"+ store.PriceList_ID_UKM.ToString() + "' and item = '" + line.Good.Articul.ToString() + "' and deleted = 0 "; MySqlCommand cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds5 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds5); prices = ds5.Tables[0]; if (prices != null) { // select item, price, version, deleted from ukmserver.trm_in_pricelist_items where pricelist_id = '" + store.PriceList_ID_UKM.ToString() + "' and deleted = 0 DataRow[] prsLsts = prices.Select("item = '" + line.Good.Articul + "'"); foreach (DataRow row in prsLsts) { price = (decimal)row[1]; } } } catch (MySqlException ex) { Response.Redirect("ErrorPage.aspx"); } finally { if (cnx != null) { cnx.Close(); } } if (price == 0) { continue; } } // if (WhithoutPrice == true) string proizvoditel = ""; string goodName = ""; int templateIDInCart = 0; PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"]; foreach (PrintTemplateCartItem itemTempl in templCart) { if (itemTempl.JourLineID == line.GoodID) { templateIDInCart = itemTempl.TemplateID; proizvoditel = itemTempl.Proizvoditel; goodName = itemTempl.GoodName; break; } } Image img = new Image(); img.ImageUrl = "Services/Cennic.ashx?LID=" + line.ID.ToString() + "&TID=" + templateIDInCart.ToString() + "&PID=" + Server.UrlEncode(proizvoditel) + "&GNID=" + Server.UrlEncode(goodName); CennicPlaceHolder1.Controls.Add(img); currCountCennic++; } } } }