public void ReadNewDataFromUKM() { string ret = ""; UKMDataBaseConnects ukm = new UKMDataBaseConnects(); ret = ukm.ReadNewData(); }
public void UKM_Quick_LoadsToDB() { string ret = ""; UKMDataBaseConnects ukm = new UKMDataBaseConnects(); ret = ukm.UKM_Quick_LoadsToDB(); }
public void InitialSetsDBSaalut() { string ret = ""; UKMDataBaseConnects ukm = new UKMDataBaseConnects(); ret = ukm.InitialDB(); }
public void NightLoadsToDB() { string ret = ""; UKMDataBaseConnects ukm = new UKMDataBaseConnects(); ret = ukm.NightLoadsToDB(); }
protected void SubmitButton1_Click(object sender, EventArgs e) { OutInfoLiteral1.Text = ""; if (context == null) { context = new SaalutDataClasses1DataContext(); } string findStr = ForFindTextBox1.Text; var goodArt = (from g in context.Goods where g.Articul == findStr select g).FirstOrDefault(); if (goodArt == null) { Int32 findInt = 0; Int32.TryParse(findStr, out findInt); var goodPlu = (from g in context.Goods where g.PLU == findInt select g).FirstOrDefault(); if (goodPlu == null) { var barcode = (from b in context.Barcodes where b.Barcode1 == findStr select b).FirstOrDefault(); if (barcode == null) { OutInfoLiteral1.Text = "Товар не найден, попробуйте найти по Артикулу или Штрих-коду или обратитесь в ИТ службу."; } else { UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.UpdateGood(barcode.Good, barcode.Good.Articul); //2 utl.UpdateGood(barcode.Good, barcode.Good.Articul); GoodInfo(barcode.Good); } } else { UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.UpdateGood(goodPlu, goodPlu.Articul); //2 utl.UpdateGood(goodPlu, goodPlu.Articul); GoodInfo(goodPlu); } } else { UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.UpdateGood(goodArt, goodArt.Articul); //2 utl.UpdateGood(goodArt, goodArt.Articul); GoodInfo(goodArt); } }
protected void LoadNewJoursButton1_Click(object sender, EventArgs e) { MessageLabel1.Text = "Загрузка данных... ждите..."; UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.ReadNewData_from_client(); MessageLabel1.Text = ""; Response.Redirect("~/NewJours.aspx"); }
protected void LoadNewJoursButton1_Click(object sender, EventArgs e) { MessageLabel1.Text = "Загрузка данных... ждите..."; UKMDataBaseConnects utl = new UKMDataBaseConnects(); MessageLabel1.Text = utl.ReadNewData_from_UKM_New_Price(); NewJoursLinqDataSource1.DataBind(); NewJoursGridView1.DataBind(); }
protected void LoadArtButton2_Click(object sender, EventArgs e) { context = new SaalutDataClasses1DataContext(); var good = (from g in context.Goods where g.Articul == ArtTextBox1.Text select g).FirstOrDefault(); UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.UpdateGood(good, ArtTextBox1.Text); }
protected void SelectTestButton1_Click(object sender, EventArgs e) { UKMDataBaseConnects ukm = new UKMDataBaseConnects(); ukm.InitialDB(); }
protected void LoadJoursButton1_Click(object sender, EventArgs e) { UKMDataBaseConnects ukm = new UKMDataBaseConnects(); MessageTextBox1.Text = ukm.ReadNewData_from_client(); }
protected void InitMatWeightButton1_Click(object sender, EventArgs e) { UKMDataBaseConnects ukm = new UKMDataBaseConnects(); MessageTextBox1.Text = ukm.InitialMatWeightDB(); }
protected void btnInitAkcionnieCeny_Click(object sender, EventArgs e) { string ret = ""; SaalutDataClasses1DataContext context = new SaalutDataClasses1DataContext(); //------------------------------- var delStoreInfo = (from d in context.StoreInfos select d).FirstOrDefault(); string jurCo = delStoreInfo.Company; string jurF = delStoreInfo.AddressFact; context.StoreInfos.DeleteOnSubmit(delStoreInfo); context.SubmitChanges(); UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.InitialStoreInfoIns(); var newStoreInfo = (from d in context.StoreInfos select d).FirstOrDefault(); newStoreInfo.Company = jurCo; newStoreInfo.AddressFact = jurF; context.SubmitChanges(); //--------------------------------- var pricesAkcion = (from p in context.PricesAkcionnies select p).FirstOrDefault(); if (pricesAkcion != null) { return; } var store = (from s in context.StoreInfos where s.Active == true select s).FirstOrDefault(); CommittableTransaction tx = new CommittableTransaction(); // Create a connection object and data adapter MySqlConnection cnx = null; try { cnx = new MySqlConnection(connStr); MySqlDataAdapter adapter = new MySqlDataAdapter(); // = делаем текущий прайс лист магазина // Выбираем магазин string cmdText = "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ; select item, price, version, deleted from ukmserver.trm_in_pricelist_items where pricelist_id = '" + store.ActPriceList_ID_UKM.ToString() + "' and deleted = 0; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ; "; MySqlCommand cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds); DataTable pricesAkcionnie = ds.Tables[0]; if (pricesAkcionnie != null) { foreach (DataRow row1 in pricesAkcionnie.Rows) { string artikulA = (string)row1[0]; decimal priceA = (decimal)row1[1]; int version_priceA = (int)row1[2]; bool delete_priceA = (bool)row1[3]; double newPriceA = Double.Parse(priceA.ToString()); var good = (from g in context.Goods where g.Articul == artikulA select g).FirstOrDefault(); if (good == null) { continue; } //+ PricesAkcionnie npr1 = new PricesAkcionnie(); npr1.GoodID = good.ID; npr1.Price = newPriceA; npr1.Version_UKM = version_priceA; npr1.TimeStamp = DateTime.Now; npr1.Active = true; context.PricesAkcionnies.InsertOnSubmit(npr1); context.SubmitChanges(); //- } } tx.Commit(); } catch (MySqlException ex) { ret += "Error: " + ex.ToString(); tx.Rollback(); } finally { if (cnx != null) { cnx.Close(); } } return; }
protected void Button1QuiqInit_Click(object sender, EventArgs e) { UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.UKM_Quick_LoadsToDB(); }
protected void Button1_Click(object sender, EventArgs e) { context = new SaalutDataClasses1DataContext(); string ret = ""; var store = (from s in context.StoreInfos where s.Active == true select s).FirstOrDefault(); if (store == null) { return; } // Create a connection object and data adapter MySqlConnection cnx = null; try { cnx = new MySqlConnection(connStr); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand cmd = new MySqlCommand("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;", cnx); cnx.Open(); cmd.ExecuteNonQuery(); //------------------------------------ var goods = from g in context.Goods select g; // items string cmdText = "select id, name, descr, measure, classif, version, deleted from ukmserver.trm_in_items where id in ('9001373','9001452','9001515','9002997','9002999','9003013','9003015','9003019','9003020','9003024','9003027','9003028','9003030','9003031','9003032','9003033','9003035','9003036','9003037','9003039','9003040','9003111','9003164','9003165','9003176','9003292','9003296','9003304','9003317','9003346','9003349','9003358','9003359') "; cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds1 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds1); DataTable items = ds1.Tables[0]; // Barcode cmdText = "select id, item, version, deleted from ukmserver.trm_in_var "; cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds2 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds2); DataTable barcodes = ds2.Tables[0]; // Assortment group items cmdText = "select ag_id, var, plu, exp_date1, exp_date2, version, deleted from ukmserver.srv_assortment_group_items where store_id = '" + store.StoreID_UKM.ToString() + "' and deleted = 0 "; cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds3 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds3); DataTable assorts = ds3.Tables[0]; // Structure cmdText = "select id, country, structure, version, deleted, producer_marking from ukmserver.trm_in_item_cc "; cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds4 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds4); DataTable structures = ds4.Tables[0]; // Prices cmdText = "select item, price, version, deleted from ukmserver.trm_in_pricelist_items where pricelist_id = '"+ store.PriceList_ID_UKM.ToString() + "' and deleted = 0 "; cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds5 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds5); DataTable prices = ds5.Tables[0]; // PrintTemplate good cmdText = "select item_id, pricetag_id, version, deleted from ukmserver.srv_pricetags_item "; cmd = new MySqlCommand(cmdText, cnx); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds6 = new DataSet(); adapter.SelectCommand = cmd; adapter.Fill(ds6); DataTable printTemplGood = ds6.Tables[0]; foreach (DataRow item in items.Rows) { string id = item[0].ToString(); var good = (from g in goods where g.Articul == id select g).FirstOrDefault(); UKMDataBaseConnects utl = new UKMDataBaseConnects(); if (good == null) { // товара нету - создаем utl.CreateNewGood(item, barcodes, assorts, structures, prices, printTemplGood); } else { utl.UpdateGood(good, item, barcodes, assorts, structures, prices, printTemplGood); } } cmd = new MySqlCommand("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ;", cnx); cmd.ExecuteNonQuery(); } catch (MySqlException ex) { ret += "Error: " + ex.ToString(); } finally { if (cnx != null) { cnx.Close(); } } return; }
public void ProcessRequest(HttpContext context) { string Division = WebConfigurationManager.AppSettings["Division"]; string journalLineID = (context.Request.QueryString["LID"]).ToUpper(); string printTmplID = (context.Request.QueryString["TID"]).ToUpper(); string proizvoditel = (context.Request.QueryString["PID"]).ToUpper(); SaalutDataClasses1DataContext dataContext = new SaalutDataClasses1DataContext(); int jlID = 0; Int32.TryParse(journalLineID, out jlID); var jl = (from j in dataContext.PriceChangeLine where j.ID == jlID select j).FirstOrDefault(); if (jl == null) { return; } var good = (from g in dataContext.Goods where g.ID == jl.GoodID select g).FirstOrDefault(); if (good == null) { return; } // settings var settings = (from s in dataContext.Settings select s).FirstOrDefault(); var store = (from s in dataContext.StoreInfos where s.Active == true select s).FirstOrDefault(); if (store == null) { return; } //+ 06052014 var storeExt = (from s in dataContext.StoreInfoExt select s).FirstOrDefault(); //- 06052014 int ptID = 0; Int32.TryParse(printTmplID, out ptID); //+07052014 if (ptID == 0) { if (good.PrintTemplateID != null) { ptID = good.PrintTemplateID.Value; } } //-07052014 var pt = (from p in dataContext.PrintTemplates where p.ID == ptID select p).FirstOrDefault(); if (pt == null) { // ищем шаблон на верхнем уровне. if (good.Group.PrintTemplateID == null) { 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 dataContext.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 { ptID = grp.PrintTemplateID.Value; break; } if (good.Group.GroupRangeID != 0 && good.Group.GroupRangeID != null) { upGroupID = good.Group.GroupRangeID.Value; } if (grp.GroupRangeID == null) { break; } } } else { ptID = good.Group.PrintTemplateID.Value; } } // проверяем нашли ли шаблон if (ptID == 0) { return; // возврат если не нашли } var template = (from t in dataContext.PrintTemplates where t.ID == ptID select t).FirstOrDefault(); if (template == null) { return; } //+ 06052014 var templateExt = (from t in dataContext.PrintTemplatesExt where t.PrintTemplateID == ptID select t).FirstOrDefault(); //- 06052014 Unit a = new Unit(template.ShirinaCennicaMM.Value, UnitTypes.Mm); int wImage = Int32.Parse(Math.Round(a.To(UnitTypes.Px).Value, 0).ToString()); //длинна картинки Unit b = new Unit(template.VisotaCennicaMM.Value, UnitTypes.Mm); int hImage = Int32.Parse(Math.Round(b.To(UnitTypes.Px).Value, 0).ToString()); //длинна картинки int otstupKray = 1; //отсутуп от края справа и снизу (справа может быть в 2 раза больше) wImage = wImage * mapSize; // увеличим размерчик для улучшения качества hImage = hImage * mapSize; int wGraph = wImage - otstupKray; int hGraph = hImage - otstupKray; Bitmap image = new Bitmap(wImage, hImage); // Get the physical path of the current application. string appPath = HttpRuntime.AppDomainAppPath; // Get the complete physical path of the file to read. string file = appPath + @"\" + template.FileName; Image backImage = Image.FromFile(file); Graphics graf = Graphics.FromImage(image); graf.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; //graf.SmoothingMode = SmoothingMode.None; //graf.InterpolationMode = InterpolationMode.Low; //graf.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.Default; //graf.PixelOffsetMode = PixelOffsetMode.None; SolidBrush whiteBrush = new SolidBrush(Color.White); SolidBrush blackBrush = new SolidBrush(Color.Black); graf.FillRectangle(blackBrush, 0, 0, wImage, hImage); if (template.TemplateName.Contains("акционный")) { graf.FillRectangle(whiteBrush, 0, 0, wImage, hImage); } else { graf.FillRectangle(whiteBrush, 1, 1, wImage - 2, hImage - 2); } // Информация ценника if (template.GoodNameFontWeight.Value != 0) { string descr = good.Descr; StringBuilder str = new StringBuilder(); descr = descr.Replace("\r\n", "\n"); descr = descr.Replace("\r", "\n"); descr = descr.Replace("\t", " "); int length = descr.Length; int from = 0; int strok = 3; //не более 3 строк в наименование while (length >= template.GoodNameSimvolovVStr) { str.Append(descr.Substring(from, template.GoodNameSimvolovVStr.Value) + "\n"); from += template.GoodNameSimvolovVStr.Value; length -= template.GoodNameSimvolovVStr.Value; if (strok == 1) { break; } strok--; } if (length < template.GoodNameSimvolovVStr) { str.Append(descr.Substring(from, length)); } string[] textParagraphs = str.ToString().Trim().Split('\n'); Font fontGoodName = new Font(FontFamily.GenericSansSerif, template.GoodNameFontWeight.Value * mapSize, FontStyle.Bold); //Font fontGoodName = new Font("Arial", 96 / 8, FontStyle.Bold); int i = 0; foreach (string strText in textParagraphs.ToArray()) { using (StringFormat sf = new StringFormat()) { if (template.GoodNameCentrovano == true) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; } else { sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Near; } sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None; sf.FormatFlags = StringFormatFlags.NoWrap; int otstPx = 0; if (i != 0) { Unit o = new Unit(template.GoodNameOtstupMM.Value, UnitTypes.Mm); otstPx = Int32.Parse(Math.Round(o.To(UnitTypes.Px).Value, 0).ToString()); //длинна картинки } graf.DrawString(strText.Trim(), fontGoodName, blackBrush, template.GoodNameX.Value * mapSize, (template.GoodNameY.Value + (i * otstPx)) * mapSize, sf); } i++; } } // + цена по новому DataTable prices; MySqlConnection cnx = null; try { cnx = new MySqlConnection(connStr); MySqlDataAdapter adapter = new MySqlDataAdapter(); // Prices string cmdText = "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ; select item, price, version, deleted from ukmserver.trm_in_pricelist_items where item = '" + good.Articul + "' and pricelist_id = '" + store.PriceList_ID_UKM.ToString() + "' and deleted = 0; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ; "; 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]; } catch (MySqlException ex) { return; } finally { if (cnx != null) { cnx.Close(); } } // - цена по новому string priceVal = "нет цены"; //var price = (from p in dataContext.Prices // where p.GoodID == good.ID // && p.Active == true // select p).FirstOrDefault(); //if (price != null) //{ // double priceFromDB = price.Price1.Value; // if (template.EdinicZa100Gr != null) // { // if (template.EdinicZa100Gr.Value) // { // priceFromDB = priceFromDB / 10; // } // } // priceVal = priceFromDB.ToString(); //} // + новая цена decimal price = 0; if (prices != null) { foreach (DataRow row in prices.Rows) { price = (decimal)row[1]; } } if (price != 0) { if (template.EdinicZa100Gr != null) { if (template.EdinicZa100Gr.Value) { price = price / 10; } } priceVal = price.ToString(); } // - новая цена string priceRub = "0"; string priceKop = "00"; int priceValZap = priceVal.IndexOf(","); if (priceValZap != -1) { priceRub = priceVal.Substring(0, priceValZap); priceKop = priceVal.Substring(priceValZap + 1, priceVal.Length - priceValZap - 1); } else { priceValZap = priceVal.IndexOf("."); if (priceValZap != -1) { priceRub = priceVal.Substring(0, priceValZap); priceKop = priceVal.Substring(priceValZap + 1, priceVal.Length - priceValZap - 1); } else { priceRub = priceVal; } } if (priceKop.Length == 1) { priceKop += "0"; } if (priceKop.Length >= 3) { priceKop = priceKop.Substring(0, 2); } if (price != 0) { int iPriceRub = Int32.Parse(priceRub); priceRub = iPriceRub.ToString("N0", CultureInfo.CreateSpecificCulture("ru-RU")); if (Division == "RF") { if (template.PriceRubFromRightToLeft == false) { if (priceRub.Length == 1) { priceRub = " " + priceRub; } if (priceRub.Length == 2) { priceRub = " " + priceRub; } if (priceRub.Length == 3) { priceRub = " " + priceRub; } } else { if (priceRub.Length == 1) { priceRub = " " + priceRub; } if (priceRub.Length == 2) { priceRub = " " + priceRub; } if (priceRub.Length == 3) { priceRub = " " + priceRub; } if (priceRub.Length == 4) { priceRub = " " + priceRub; } } } else if (Division == "RB") { if (priceRub.Length == 2) { priceRub = " " + priceRub; } if (priceRub.Length == 3) { priceRub = " " + priceRub; } if (priceRub.Length == 4) { priceRub = " " + priceRub; } if (priceRub.Length == 5) { priceRub = " " + priceRub; } if (priceRub.Length == 6) { priceRub = " " + priceRub; } if (priceRub.Length == 7) { priceRub = " " + priceRub; } } } if (template.PriceRubFontWeight.Value != 0) { Font fontPriceRub = new Font("Arial black", template.PriceRubFontWeight.Value * mapSize, FontStyle.Bold); //Font fontPriceRub = new Font("Arial black", 64, FontStyle.Bold); graf.DrawString(priceRub, fontPriceRub, blackBrush, template.PriceRubX.Value * mapSize, template.PriceRubY.Value * mapSize); } if (template.SlovoRubFontWeigh.Value != 0) { Font font = new Font(FontFamily.GenericSansSerif, template.SlovoRubFontWeigh.Value * mapSize, FontStyle.Regular); if (template.SlovoRubUnderline.Value == true) { font = new Font(FontFamily.GenericSansSerif, template.SlovoRubFontWeigh.Value * mapSize, FontStyle.Underline); } graf.DrawString("РУБ", font, blackBrush, template.SlovoRubX.Value * mapSize, template.SlovoRubY.Value * mapSize); } if (template.PriceKopFontWeight.Value != 0 && Division != "RB") { Font fontPriceKop = new Font("Arial black", template.PriceKopFontWeight.Value * mapSize, FontStyle.Bold); graf.DrawString(priceKop, fontPriceKop, blackBrush, template.PriceKopX.Value * mapSize, template.PriceKopY.Value * mapSize); } if (template.SlovoKopFontWeight.Value != 0 && Division != "RB") { Font font = new Font(FontFamily.GenericSansSerif, template.SlovoKopFontWeight.Value * mapSize, FontStyle.Regular); if (template.SlovoKopUnderline.Value == true) { font = new Font(FontFamily.GenericSansSerif, template.SlovoKopFontWeight.Value * mapSize, FontStyle.Underline); } graf.DrawString("КОП", font, blackBrush, template.SlovoKopX.Value * mapSize, template.SlovoKopY.Value * mapSize); } if (!template.EdinicZa100Gr.Value && template.EdinicFontWeight.Value != 0) { Font fontEdinic = new Font(FontFamily.GenericSansSerif, template.EdinicFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString("ед.изм.: " + good.Edinic, fontEdinic, blackBrush, template.EdinicX.Value * mapSize, template.EdinicY.Value * mapSize); } if (template.EdinicZa100Gr.Value && template.EdinicFontWeight.Value != 0) { Font fontEdinic = new Font(FontFamily.GenericSansSerif, template.EdinicFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString("Цена за 100 гр.", fontEdinic, blackBrush, template.EdinicX.Value * mapSize, template.EdinicY.Value * mapSize); } if (template.SostavFontWeight.Value != 0) { string Contents = good.Contents.Trim(); if (Contents != "") { if (Contents.Substring(0, 6).ToUpper() != "СОСТАВ") { Contents = "Состав: " + Contents; } } StringBuilder str = new StringBuilder(); Contents = Contents.Replace("\r\n", "\n"); Contents = Contents.Replace("\r", "\n"); Contents = Contents.Replace("\t", " "); int length = Contents.Length; int from = 0; while (length >= template.SostavSimvolovVStr) { str.Append(Contents.Substring(from, template.SostavSimvolovVStr.Value) + "\n"); from += template.SostavSimvolovVStr.Value; length -= template.SostavSimvolovVStr.Value; } if (length < template.SostavSimvolovVStr) { str.Append(Contents.Substring(from, length)); } string[] textParagraphs = str.ToString().Trim().Split('\n'); Font fontSostav = new Font(FontFamily.GenericSansSerif, template.SostavFontWeight.Value * mapSize, FontStyle.Regular); int i = 0; foreach (string strText in textParagraphs.ToArray()) { using (StringFormat sf = new StringFormat()) { sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Near; sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None; sf.FormatFlags = StringFormatFlags.NoWrap; int otstPx = 0; if (i != 0) { Unit o = new Unit(template.SostavOtstupMM.Value, UnitTypes.Mm); otstPx = Int32.Parse(Math.Round(o.To(UnitTypes.Px).Value, 0).ToString()); //длинна картинки } graf.DrawString(strText.Trim(), fontSostav, blackBrush, template.SostavX.Value * mapSize, (template.SostavY.Value + (i * otstPx)) * mapSize); } i++; } } if (template.ProizvoditelFontWeight.Value != 0) { string contsts = good.Producer; if (contsts.Length > 0) { contsts = contsts.Substring(0, 1).ToUpper() + contsts.Substring(1).ToLower(); } contsts += " " + proizvoditel; Font fontProizvoditel = new Font(FontFamily.GenericSansSerif, template.ProizvoditelFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString((contsts).Trim(), fontProizvoditel, blackBrush, template.ProizvoditeX.Value * mapSize, template.ProizvoditeY.Value * mapSize); } if (template.MagazinFontWeight.Value != 0) { if (store != null) { Font fontMagazin = new Font(FontFamily.GenericSansSerif, template.MagazinFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(store.StoreName.Trim(), fontMagazin, blackBrush, template.MagazinX.Value * mapSize, template.MagazinY.Value * mapSize); } } if (template.JurlicoFontWeight.Value != 0) { if (store != null) { if (store.Company != null) { Font font = new Font(FontFamily.GenericSansSerif, template.JurlicoFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(store.Company.Trim(), font, blackBrush, template.JurlicoX.Value * mapSize, template.JurlicoY.Value * mapSize); } } } if (template.FactAddressFontWeight.Value != 0) { if (store != null) { if (store.AddressFact != null) { Font fontAddressFact = new Font(FontFamily.GenericSansSerif, template.FactAddressFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(store.AddressFact.Trim(), fontAddressFact, blackBrush, template.FactAddressX.Value * mapSize, template.FactAddressY.Value * mapSize); } } } if (template.JurAddressFontWeight.Value != 0) { if (store != null) { if (store.AddressJur != null) { Font fontAddressJur = new Font(FontFamily.GenericSansSerif, template.JurAddressFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(store.AddressJur.Trim(), fontAddressJur, blackBrush, template.JurAddressX.Value * mapSize, template.JurAddressY.Value * mapSize); } } } if (template.DataFontWeight.Value != 0) { Font fontData = new Font(FontFamily.GenericSansSerif, template.DataFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString("Дата:" + DateTime.Today.ToString("dd.MM"), fontData, blackBrush, template.DataX.Value * mapSize, template.DataY.Value * mapSize); } //Image img = image.GetThumbnailImage(wImage / mapSize, hImage / mapSize, null, (new System.IntPtr(0))); if (template.BarcodeShirinaMM.Value != -1 && template.BarcodeVisotaMM.Value != -1) { Graphics graf2 = Graphics.FromImage(image); string barcode = good.Barcode; if (barcode == "" || barcode == "0" || barcode == null) // bug fix { var barkodes_all = (from brk in dataContext.Barcodes where brk.GoodID == good.ID && brk.Active == true select brk).FirstOrDefault(); if (barkodes_all != null) { barcode = barkodes_all.Barcode1; } } //bug fix if (barcode == "" || barcode == "0" || barcode == null) { UKMDataBaseConnects utl = new UKMDataBaseConnects(); utl.UpdateGood(good, good.Articul); //2 utl.UpdateGood(good, good.Articul); } if (barcode.Length >= 13) { barcode = barcode.Substring(0, 12); } if (barcode.Length < 12) { int ii = 12 - barcode.Length; for (int i = 1; i <= ii; i++) { barcode += "0"; } } BarcodeEAN13 encoderEAN13 = new BarcodeEAN13(); Image barcImg = encoderEAN13.Encode(barcode); Rectangle nr = new Rectangle(0, barcImg.Height / 2, barcImg.Width, barcImg.Height / 3); if (settings != null) { if (template.BarcodeShirinaMM.Value != 0 && template.BarcodeVisotaMM.Value != 0) { //if (settings.ResizeBarcodes.Value) //{ Unit c = new Unit(template.BarcodeShirinaMM.Value, UnitTypes.Mm); int wBC = Int32.Parse(Math.Round(c.To(UnitTypes.Px).Value, 0).ToString()); //длинна картинки Unit d = new Unit(template.BarcodeVisotaMM.Value, UnitTypes.Mm); int hBC = Int32.Parse(Math.Round(d.To(UnitTypes.Px).Value, 0).ToString()); //длинна картинки graf2.DrawImage(this.ResizeImg(barcImg, wBC, hBC), new Point(template.BarcodeX.Value, template.BarcodeY.Value)); } else { if (templateExt != null) { if (templateExt.MalenkiyBarcode.Value == true) { graf2.DrawImage(this.cropImage(barcImg, nr), new Point(template.BarcodeX.Value, template.BarcodeY.Value)); } else { graf2.DrawImage(barcImg, new Point(template.BarcodeX.Value, template.BarcodeY.Value)); } } else { graf2.DrawImage(this.cropImage(barcImg, nr), new Point(template.BarcodeX.Value, template.BarcodeY.Value)); } } } else { graf2.DrawImage(barcImg, new Point(template.BarcodeX.Value, template.BarcodeY.Value)); } } //+ 06052014 PrintTemplateExt decimal priceOld = 0; if (storeExt != null) { DataTable pricesOld; MySqlConnection cnxOld = null; try { cnxOld = new MySqlConnection(connStr); MySqlDataAdapter adapterOld = new MySqlDataAdapter(); // Prices string cmdText = "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ; select item, price, version, deleted from ukmserver.trm_in_pricelist_items where item = '" + good.Articul + "' and pricelist_id = '" + storeExt.OsnPriceList_ID_UKM.ToString() + "' and deleted = 0; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ; "; MySqlCommand cmd = new MySqlCommand(cmdText, cnxOld); cmd.CommandTimeout = 30000; // Create a fill a Dataset DataSet ds5 = new DataSet(); adapterOld.SelectCommand = cmd; adapterOld.Fill(ds5); pricesOld = ds5.Tables[0]; } catch (MySqlException ex) { return; } finally { if (cnxOld != null) { cnxOld.Close(); } } string priceValOld = ""; //var price = (from p in dataContext.Prices // where p.GoodID == good.ID // && p.Active == true // select p).FirstOrDefault(); //if (price != null) //{ // double priceFromDB = price.Price1.Value; // if (template.EdinicZa100Gr != null) // { // if (template.EdinicZa100Gr.Value) // { // priceFromDB = priceFromDB / 10; // } // } // priceVal = priceFromDB.ToString(); //} if (pricesOld != null) { foreach (DataRow row in pricesOld.Rows) { priceOld = (decimal)row[1]; } } if (priceOld != 0) { if (template.EdinicZa100Gr != null) { if (template.EdinicZa100Gr.Value) { priceOld = priceOld / 10; } } priceValOld = priceOld.ToString(); } string priceRubOld = "0"; string priceKopOld = "00"; int priceValZapOld = priceValOld.IndexOf(","); if (priceValZapOld != -1) { priceRubOld = priceValOld.Substring(0, priceValZapOld); priceKopOld = priceValOld.Substring(priceValZapOld + 1, priceValOld.Length - priceValZapOld - 1); } else { priceValZapOld = priceValOld.IndexOf("."); if (priceValZapOld != -1) { priceRubOld = priceValOld.Substring(0, priceValZapOld); priceKopOld = priceValOld.Substring(priceValZapOld + 1, priceValOld.Length - priceValZapOld - 1); } else { priceRubOld = priceValOld; } } if (priceKopOld.Length == 1) { priceKopOld += "0"; } if (priceKopOld.Length >= 3) { priceKopOld = priceKopOld.Substring(0, 2); } if (priceOld != 0) { int iPriceRubOld = Int32.Parse(priceRubOld); priceRubOld = iPriceRubOld.ToString("N0", CultureInfo.CreateSpecificCulture("ru-RU")); if (Division == "RF") { if (priceRubOld.Length == 1) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 2) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 3) { priceRubOld = " " + priceRubOld; } } else if (Division == "RB") { if (priceRubOld.Length == 2) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 3) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 4) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 5) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 6) { priceRubOld = " " + priceRubOld; } if (priceRubOld.Length == 7) { priceRubOld = " " + priceRubOld; } } } if (template.OldPriceRubFontWeight.Value != 0) { Font fontPriceRub = new Font(FontFamily.GenericSansSerif, template.OldPriceRubFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(priceRubOld, fontPriceRub, blackBrush, template.OldPriceRubX.Value * mapSize, template.OldPriceRubY.Value * mapSize); } if (template.OldSlovoRubFontWeigh.Value != 0) { Font font = new Font(FontFamily.GenericSansSerif, template.OldSlovoRubFontWeigh.Value * mapSize, FontStyle.Regular); graf.DrawString("РУБ", font, blackBrush, template.OldSlovoRubX.Value * mapSize, template.OldSlovoRubY.Value * mapSize); } if (template.OldPriceKopFontWeight.Value != 0 && Division != "RB") { Font fontPriceKop = new Font(FontFamily.GenericSansSerif, template.OldPriceKopFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(priceKopOld, fontPriceKop, blackBrush, template.OldPriceKopX.Value * mapSize, template.OldPriceKopY.Value * mapSize); } if (template.OldSlovoKopFontWeight.Value != 0 && Division != "RB") { Font font = new Font(FontFamily.GenericSansSerif, template.OldSlovoKopFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString("КОП", font, blackBrush, template.OldSlovoKopX.Value * mapSize, template.OldSlovoKopY.Value * mapSize); } } if (templateExt != null) { if (templateExt.SlovoCenaFontWeight.Value != 0) { Font fontData = new Font(FontFamily.GenericSansSerif, templateExt.SlovoCenaFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(templateExt.SlovoCena, fontData, blackBrush, templateExt.SlovoCenaX.Value * mapSize, templateExt.SlovoCenaY.Value * mapSize); } if (templateExt.DopTextFontWeight.Value != 0) { double priceOldD = Double.Parse(priceOld.ToString()); double priceD = Double.Parse(price.ToString()); double percentDec = (priceOldD - priceD) / priceOldD * 100; percentDec = Math.Round(percentDec); Font fontData = new Font(FontFamily.GenericSansSerif, templateExt.DopTextFontWeight.Value * mapSize, FontStyle.Bold); graf.DrawString(templateExt.DopText + " " + percentDec.ToString() + "%", fontData, blackBrush, templateExt.DopTextX.Value * mapSize, templateExt.DopTextY.Value * mapSize); } if (templateExt.SlovoObichCenaFontWeight.Value != 0) { Font fontData = new Font(FontFamily.GenericSansSerif, templateExt.SlovoObichCenaFontWeight.Value * mapSize, FontStyle.Regular); graf.DrawString(templateExt.SlovoObichCena, fontData, blackBrush, templateExt.SlovoObichCenaX.Value * mapSize, templateExt.SlovoObichCenaY.Value * mapSize); } } //- 06052014 MemoryStream memStream = new MemoryStream(); context.Response.ContentType = "image/png"; image.Save(memStream, ImageFormat.Png); memStream.WriteTo(context.Response.OutputStream); graf.Dispose(); image.Dispose(); backImage.Dispose(); }