예제 #1
0
        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();
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (context == null)
            {
                context = new SaalutDataClasses1DataContext();
            }

            if (!IsPostBack)
            {
                Session["JourCart"] = new JourCart();

                Session["PrintTemplateCart"] = new PrintTemplateCart();
            }
        }
예제 #3
0
        protected void FindButton1_Click(object sender, EventArgs e)
        {
            Session["PrintTemplateCart"] = new PrintTemplateCart();

            string[] textParagraphs = ForFindTextBox1.Text.Split('\n');
            string[] newTP          = new string[textParagraphs.Length];

            int i = 0;

            foreach (string str in textParagraphs)
            {
                string strT = str.Replace("\r", "");
                newTP[i] = strT;
                i++;
            }


            var goods = from g in context.Goods
                        where newTP.Contains(g.Articul)
                        select g;

            if (goods.Count() == 0)
            {
                var barcodes = from b in context.Barcodes
                               where newTP.Contains(b.Barcode1) &&
                               b.Active == true    // bug fix barkode
                               select b.GoodID.Value;
                List <int> listOfIDs = barcodes.ToList();
                var        goodsBC   = from g in context.Goods
                                       where listOfIDs.Contains(g.ID)
                                       select g;
                GoodsGridView1.DataSource = goodsBC;
                GoodsGridView1.DataBind();
            }
            else
            {
                GoodsGridView1.DataSource = goods;
                GoodsGridView1.DataBind();
            }

            foreach (Good good in goods)
            {
                AddToCartTemplate(good.ID, 0, good.Country, good.Descr);
            }
        }
예제 #4
0
        protected void AddToCartTemplate(int jourLineID, int printTemplID, string proizvoditel, string goodName)
        {
            PrintTemplateCart cart = (PrintTemplateCart)Session["PrintTemplateCart"];

            int i = 0;

            //Boolean inCart = false;
            foreach (PrintTemplateCartItem items in cart)
            {
                if (items.JourLineID == jourLineID)
                {
                    cart.RemoveAt(i);
                    //inCart = true;
                    break;
                }
                i++;
            }

            //if (!inCart)
            {
                PrintTemplateCartItem item = new PrintTemplateCartItem(jourLineID, printTemplID, proizvoditel, goodName);
                cart.Add(item);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        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;
                            }
                        }
                    }
                } // большой ценник
            }
        }
예제 #7
0
        private int FindTemplate(int priceJourLine)
        {
            var priceLine = (from p in context.PriceChangeLine
                             where p.ID == priceJourLine
                             select p).FirstOrDefault();

            if (priceLine == null)
            {
                return(0);
            }

            int ptID = 0;

            if (priceLine.Good != null)
            {
                if (priceLine.Good.PrintTemplateID != null)
                {
                    ptID = priceLine.Good.PrintTemplateID.Value;
                }
            }

            if (ptID == 0)
            {
                var good = (from g in context.Goods
                            where g.ID == priceLine.GoodID
                            select g).FirstOrDefault();

                if (good == null)
                {
                    return(0);
                }

                // ищем шаблон на верхнем уровне.
                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 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
                        {
                            ptID = grp.PrintTemplateID.Value;
                            break;
                        }

                        if (good.Group.GroupRangeID != 0 && good.Group.GroupRangeID != null)
                        {
                            upGroupID = good.Group.GroupRangeID.Value;
                        }
                    }
                }
                else
                {
                    ptID = good.Group.PrintTemplateID.Value;
                }
            }


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

            foreach (PrintTemplateCartItem itemTempl in templCart)
            {
                if (itemTempl.JourLineID == priceJourLine)
                {
                    ptID = itemTempl.TemplateID;

                    break;
                }
            }

            return(ptID);
        }
예제 #8
0
        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++;
                    }
                }
            }
        }
예제 #9
0
        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++;
                    }
                }
            }
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
        protected void GoodsGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int LineID = (int)DataBinder.Eval(e.Row.DataItem, "ID");

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

                var good = (from g in context.Goods
                            where g.ID == LineID
                            select g).FirstOrDefault();

                TextBox ProizvoditelTextBox1 = (TextBox)e.Row.FindControl("ProizvoditelTextBox1");
                TextBox GoodNameTextBox1     = (TextBox)e.Row.FindControl("GoodNameTextBox1");

                // set def value
                if (GoodNameTextBox1.Text == "")
                {
                    GoodNameTextBox1.Text = good.Descr;
                }
                if (ProizvoditelTextBox1.Text == "")
                {
                    ProizvoditelTextBox1.Text = good.Country;
                }

                // шаблон ценников

                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 (printTemplGroupId != 0)
                            {
                                templateIDInCart = printTemplGroupId;
                            }
                            else
                            {
                                templateIDInCart = printTempls.FirstOrDefault().ID;
                            }
                        }
                    }
                    else
                    {
                        templateIDInCart = printTempls.FirstOrDefault().ID;
                    }
                }

                // + цена по новому
                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)
                {
                    priceVal = price.ToString();
                    if (Division == "RF")
                    {
                        priceVal = priceVal.Substring(0, priceVal.Length - 2);
                    }
                    else
                    if (Division == "RB")
                    {
                        priceVal = priceVal.Substring(0, priceVal.Length - 5);
                    }
                }
                // - новая цена
                Label GoodPriceLabel1 = (Label)e.Row.FindControl("GoodPriceLabel1");
                GoodPriceLabel1.Text = priceVal;

                PrintTemplateDropDownList1.SelectedValue = templateIDInCart.ToString();
                PrintTemplateDropDownList1.DataBind();


                AddToCartTemplate(LineID, templateIDInCart, ProizvoditelTextBox1.Text, GoodNameTextBox1.Text);
                //- конец шаблоны ценников
            }
        }