Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        protected void PrintRightNow_Click2(object sender, EventArgs e)
        {
            if (context == null)
            {
                context = new SaalutDataClasses1DataContext();
            }

            var setting = (from s in context.Settings
                           select s).FirstOrDefault();

            if (setting.MobileTermoPrinterNetPath == null || setting.MobileTermoPrinterNetPath == "")
            {
                PriceLabel1.Text = "Нет настроек печати!";
                return;
            }

            var template = (from t in context.TermoCennic
                            where t.Active == true
                            select t).FirstOrDefault();

            if (template == null)
            {
                PriceLabel1.Text = "Нет шаблона печати!";
                return;
            }



            var store = (from s in context.StoreInfos
                         where s.Active == true
                         select s).FirstOrDefault();

            string barcodeText = BarcodeTextBox1.Text.Trim();

            var barcode = (from p in context.Barcodes
                           where p.Barcode1 == barcodeText &&
                           p.Active == true    // bug fix barkode
                           select p).FirstOrDefault();

            if (barcode == null)
            {
                PriceLabel1.Text = "Ш/К не найден.";
                return;
            }

            var lineCheck = (from l in context.PriceChangeLine
                             where l.JournalID == jourID &&
                             l.GoodID == barcode.GoodID
                             select l).FirstOrDefault();

            if (lineCheck == null)
            {
                PriceChangeLine nl = new PriceChangeLine();
                nl.GoodID     = barcode.GoodID;
                nl.JournalID  = jourID;
                nl.ItemID_UKM = barcode.Good.Articul;

                nl.Active    = true;
                nl.TimeStamp = DateTime.Now;
                nl.Akcionniy = false;
                context.PriceChangeLine.InsertOnSubmit(nl);
            }

            TermoCennicQuoue cq = new TermoCennicQuoue();

            cq.JournalID     = jourID;
            cq.GoodID        = barcode.GoodID;
            cq.TermoCennicID = template.ID;
            cq.TimeStamp     = DateTime.Now;
            cq.Active        = true;
            context.TermoCennicQuoue.InsertOnSubmit(cq);


            context.SubmitChanges();

            PriceLabel1.Text     = "";
            BarcodeTextBox1.Text = "";


            PrintRightNow.Enabled = false;
            //PrintRightNow2.Enabled = false;
            AddToJournalButton1.Focus();

            PriceLabel1.Text = "Отправлено на печать!";
        }
Ejemplo n.º 3
0
        protected void TermoCennicButton1_Click(object sender, EventArgs e)
        {
            int      newJournalID = 0;
            DateTime tst          = DateTime.Now;

            // создадим темповый журнал
            if (GoodsGridView1.Rows.Count != 0)
            {
                PriceChangeJour np = new PriceChangeJour();
                np.Change_log_id_UKM = 0;
                np.Order_no          = 0;
                np.InUse             = false;
                np.TimeStamp         = tst;
                np.Active            = true;
                context.PriceChangeJours.InsertOnSubmit(np);
                context.SubmitChanges();
            }
            else
            {
                return;
            }

            var journTMP = (from t in context.PriceChangeJours
                            where t.TimeStamp == tst
                            select t).FirstOrDefault();

            newJournalID = journTMP.ID;


            PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"];

            foreach (PrintTemplateCartItem item in templCart)
            {
                var good = (from g in context.Goods
                            where g.ID == item.JourLineID
                            select g).FirstOrDefault();
                if (good == null)
                {
                    continue;
                }

                PriceChangeLine nl = new PriceChangeLine();
                nl.Good       = good;
                nl.JournalID  = newJournalID;
                nl.ItemID_UKM = good.Articul;
                Price price = (from p in context.Prices
                               where p.GoodID == good.ID &&
                               p.Active == true
                               select p).FirstOrDefault();
                if (price != null)
                {
                    nl.NewPrice = price.Price1.Value;
                }
                else
                {
                    nl.NewPrice = 0;
                }
                nl.Active    = true;
                nl.TimeStamp = tst;
                context.PriceChangeLine.InsertOnSubmit(nl);
            }
            context.SubmitChanges();

            var jourlines = from j in context.PriceChangeLine
                            where j.JournalID == newJournalID
                            select j;

            foreach (PriceChangeLine ln in jourlines)
            {
                AddToCart(ln.ID);
            }


            string url = "CennicListTermo.aspx?ID=" + newJournalID.ToString() + "&q=" + QtyTermoPTextBox1.Text + "&f=" + TermPrinterDropDownList1.SelectedValue;

            ////string redirectScript = "<script>window.open('" + url + "');</script>";
            ////Response.Write(redirectScript);


            Response.Redirect(url);
        }
Ejemplo n.º 4
0
        protected void AddToJournalButton1_Click(object sender, EventArgs e)
        {
            var store = (from s in context.StoreInfos
                         where s.Active == true
                         select s).FirstOrDefault();

            string barcodeText = BarcodeTextBox1.Text.Trim();
            //string counted = BarcodeTextBox2.Text.Trim();
            string counted = BarcodeTextBox2.Text.Trim();
            var    barcode = (from p in context.Barcodes
                              where p.Barcode1 == barcodeText &&
                              p.Active == true // bug fix barkode
                              select p).FirstOrDefault();

            if (barcode == null)
            {
                PriceLabel1.Text = "Ш/К не найден.";
                return;
            }

            // добавили дату алко, удаляем добавление количества
            //var lineCheck = (from l in context.PriceChangeLine
            //                 where l.JournalID == jourID
            //                 && l.GoodID == barcode.GoodID
            //                 select l).FirstOrDefault();
            //if (lineCheck != null)
            //{
            //    PriceLabel1.Text = "Товар уже в журнале. Количество добавлено";
            //    //lineCheck.Counted += Convert.ToInt32(counted);
            //    PriceChangeLine nlt = new PriceChangeLine();
            //    nlt.Active = lineCheck.Active;
            //    nlt.Akcionniy = lineCheck.Akcionniy;
            //    nlt.counted = lineCheck.counted + Convert.ToInt32(counted);
            //    nlt.Good = lineCheck.Good;
            //    nlt.GoodID = lineCheck.GoodID;
            //    nlt.ID = lineCheck.ID;
            //    nlt.ItemID_UKM = lineCheck.ItemID_UKM;
            //    nlt.JournalID = lineCheck.JournalID;
            //    nlt.NewPrice = lineCheck.NewPrice;
            //    nlt.PriceChangeJour = lineCheck.PriceChangeJour;
            //    nlt.TimeStamp = lineCheck.TimeStamp;
            //    nlt.alcoDt = AlcoDateTextBox1.Text;

            //    context.PriceChangeLine.DeleteOnSubmit(lineCheck);
            //    context.SubmitChanges();
            //    // context.PriceChangeLines.InsertOnSubmit(nlt);
            //    // context.SubmitChanges();

            //    // PriceLabel1.Text = "";
            //    BarcodeTextBox1.Text = "";
            //    BarcodeTextBox2.Text = "1";
            //    JourLinesLinqDataSource1.DataBind();
            //    JourLinesGridView1.DataBind();
            //    return;
            //}

            PriceChangeLine nl = new PriceChangeLine();

            nl.GoodID     = barcode.GoodID;
            nl.JournalID  = jourID;
            nl.ItemID_UKM = barcode.Good.Articul;
            nl.counted    = Convert.ToInt32(counted);
            nl.alcoDt     = AlcoDateTextBox1.Text;

            //var price = (from p in context.Prices
            //             where p.GoodID == barcode.GoodID
            //             && p.Active == true
            //             select p).FirstOrDefault();
            //if (price == null)
            //{

            //    nl.NewPrice = 0;
            //}
            //else
            //    nl.NewPrice = price.Price1;

            // цены укм
            // Create a connection object and data adapter
            DataTable       prices;
            decimal         price = 0;
            MySqlConnection cnx   = null;

            try
            {
                cnx = new MySqlConnection(connStr);
                MySqlDataAdapter adapter = new MySqlDataAdapter();

                // Prices
                string       cmdText = "select item, price, version, deleted	from ukmserver.trm_in_pricelist_items where item = '"+ barcode.Good.Articul + "' and pricelist_id = '" + store.PriceList_ID_UKM.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)
                {
                    foreach (DataRow row in prices.Rows)
                    {
                        price = (decimal)row[1];
                    }
                }
            }
            catch (MySqlException ex)
            {
                nl.NewPrice = 0;
            }
            finally
            {
                if (cnx != null)
                {
                    cnx.Close();
                }
            }

            Double dPrice = 0;

            Double.TryParse(price.ToString(), out dPrice);
            nl.NewPrice = dPrice;

            nl.Active    = true;
            nl.TimeStamp = DateTime.Now;
            nl.Akcionniy = false;
            context.PriceChangeLine.InsertOnSubmit(nl);
            context.SubmitChanges();

            PriceLabel1.Text     = "";
            BarcodeTextBox1.Text = "";
            BarcodeTextBox2.Text = "1";
            JourLinesLinqDataSource1.DataBind();
            JourLinesGridView1.DataBind();
        }
Ejemplo n.º 5
0
        protected void CennicButton1_Click(object sender, EventArgs e)
        {
            int      newJournalID = 0;
            DateTime tst          = DateTime.Now;

            // создадим темповый журнал
            if (GoodsGridView1.Rows.Count != 0)
            {
                PriceChangeJour np = new PriceChangeJour();
                np.Change_log_id_UKM = 0;
                np.Order_no          = 0;
                np.InUse             = false;
                np.TimeStamp         = tst;
                np.Active            = true;
                context.PriceChangeJours.InsertOnSubmit(np);
                context.SubmitChanges();
            }
            else
            {
                return;
            }

            var journTMP = (from t in context.PriceChangeJours
                            where t.TimeStamp == tst
                            select t).FirstOrDefault();

            newJournalID = journTMP.ID;


            PrintTemplateCart templCart = (PrintTemplateCart)Session["PrintTemplateCart"];

            foreach (PrintTemplateCartItem item in templCart)
            {
                var good = (from g in context.Goods
                            where g.ID == item.JourLineID
                            select g).FirstOrDefault();
                if (good == null)
                {
                    continue;
                }

                if (CheckBox1WhithoutPrice.Checked == true)
                {
                    var prs = (from p in context.Prices
                               where p.GoodID == good.ID &&
                               p.Active == true
                               select p).FirstOrDefault();
                    if (prs == null)
                    {
                        continue;
                    }
                }

                PriceChangeLine nl = new PriceChangeLine();
                nl.Good       = good;
                nl.JournalID  = newJournalID;
                nl.ItemID_UKM = good.Articul;
                Price price = (from p in context.Prices
                               where p.GoodID == good.ID &&
                               p.Active == true
                               select p).FirstOrDefault();
                if (price != null)
                {
                    nl.NewPrice = price.Price1.Value;
                }
                else
                {
                    nl.NewPrice = 0;
                }
                nl.Active    = true;
                nl.TimeStamp = tst;
                context.PriceChangeLine.InsertOnSubmit(nl);
            }
            context.SubmitChanges();


            //foreach (GridViewRow row in GoodsGridView1.Rows)
            //{
            //    Label GoodIDLabel1 = (Label)row.FindControl("GoodIDLabel1");
            //    DropDownList PrintTemplateDropDownList1 = (DropDownList)row.FindControl("PrintTemplateDropDownList1");

            //    int goodid = Int32.Parse(GoodIDLabel1.Text);
            //    int printTempl = Int32.Parse(PrintTemplateDropDownList1.SelectedValue);

            //    var good = (from g in context.Goods
            //                where g.ID == goodid
            //                select g).FirstOrDefault();
            //    if (good == null)
            //        continue;

            //    PriceChangeLine nl = new PriceChangeLine();
            //    nl.Good = good;
            //    nl.JournalID = newJournalID;
            //    nl.ItemID_UKM = good.Articul;
            //    Price price = (from p in context.Prices
            //                   where p.GoodID == goodid
            //                   && p.Active == true
            //                   select p).FirstOrDefault();
            //    if (price != null)
            //        nl.NewPrice = price.Price1.Value;
            //    else
            //        nl.NewPrice = 0;
            //    nl.Active = true;
            //    nl.TimeStamp = tst;
            //    context.PriceChangeLine.InsertOnSubmit(nl);
            //}
            //context.SubmitChanges();


            string url = "CennicList.aspx?ID=" + newJournalID.ToString();

            ////string redirectScript = "<script>window.open('" + url + "');</script>";
            ////Response.Write(redirectScript);


            Response.Redirect(url);
        }