예제 #1
0
        protected void Button2_Click1(object sender, EventArgs e)
        {
            if ((!IsNullOrEmpty((Request.Form[TextBox5.UniqueID]))))
            {
                Label3.Text = "";
                context     = new ContextModelEntity();
                var dstoreKepper = context.StoreKeeperSet
                                   .Where(c => c.LastFierstName == DropDownList1.SelectedValue.ToString()).FirstOrDefault();
                if (context.DitailsSet != null)
                {
                    int num;
                    if (TextBox3 != null)
                    {
                        num = Convert.ToInt32(TextBox3.Text);


                        var details = context.DitailsSet
                                      .Where(c => c.NameIdCode == TextBox1.Text)
                                      .Where(c => c.NameDetails == TextBox2.Text)
                                      .Where(c => c.Quantity == num)
                                      .Where(c => c.StoreKeeper == dstoreKepper.Id).FirstOrDefault();
                        DateTime dob = DateTime.Parse(Request.Form[TextBox5.UniqueID]);

                        details.DateDelete = dob;
                    }

                    context.SaveChanges();
                    Response.Redirect("Default.aspx");
                }
            }
            else
            {
                Label3.Text = "Выберите дату";
            }
        }
예제 #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(TextBox1.Text))
            {
                context = new ContextModelEntity();
                if (context.StoreKeeperSet != null)
                {
                    List <string> listKeeper = new List <string>();
                    var           kepper     = context.StoreKeeperSet;
                    foreach (var itemKeeper in kepper)
                    {
                        listKeeper.Add(itemKeeper.LastFierstName);
                    }

                    if (!listKeeper.Contains(TextBox1.Text))
                    {
                        StoreKeeper storeKeeper = new StoreKeeper();
                        storeKeeper.LastFierstName = TextBox1.Text;
                        context.StoreKeeperSet.Add(storeKeeper);
                        context.SaveChanges();
                        Response.Redirect("Default2.aspx");
                    }
                }
            }
        }
예제 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(DropDownList1.SelectedValue))
            {
                context = new ContextModelEntity();

                bool coutBool    = false;
                var  storeKepper = context.StoreKeeperSet
                                   .Where(c => c.LastFierstName == DropDownList1.SelectedValue.ToString()).FirstOrDefault();
                var dateils = context.DitailsSet
                              .Where(c => c.StoreKeeper == storeKepper.Id).ToList();

                foreach (Ditails iteDitails in storeKepper.Ditails.ToArray())
                {
                    if (iteDitails.DateDelete != null)
                    {
                        context.DitailsSet.Remove(iteDitails);
                        coutBool = true;
                    }
                }

                if (coutBool)
                {
                    context.StoreKeeperSet.Remove(storeKepper);
                    context.SaveChanges();

                    Response.Redirect("Default2.aspx");
                }
                List <int> numberDetails = new List <int>();
                int        count         = 0;
                int        count2        = 0;
                foreach (var itemDitailse in context.DitailsSet)
                {
                    if (itemDitailse.StoreKeeper == storeKepper.Id)
                    {
                        count++;
                        if (itemDitailse.DateDelete != null)
                        {
                            count2++;
                        }
                    }
                }

                if (count == count2)
                {
                    context.StoreKeeperSet.Remove(storeKepper);
                    context.SaveChanges();
                    Response.Redirect("Default2.aspx");
                }
            }
        }
예제 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue.ToString() != "Выберите кладовщика")
            {
                if (!IsNullOrEmpty(TextBox3.Text))
                {
                    if (!IsNullOrEmpty((Request.Form[TextBox4.UniqueID])))
                    {
                        if (Page.IsValid)
                        {
                            Ditails  details = new Ditails();
                            DateTime dob     = DateTime.Parse(Request.Form[TextBox4.UniqueID]);
                            details.DateAdd     = dob;
                            details.NameIdCode  = TextBox1.Text;
                            details.NameDetails = TextBox2.Text;
                            int quantity;
                            if (int.TryParse(TextBox3.Text, out quantity))
                            {
                                details.Quantity = quantity;
                            }

                            context = new ContextModelEntity();
                            if (context.StoreKeeperSet != null)
                            {
                                foreach (var storKeeper in context.StoreKeeperSet)
                                {
                                    if (storKeeper.LastFierstName == DropDownList1.SelectedValue.ToString())
                                    {
                                        details.StoreKeeper = storKeeper.Id;
                                    }
                                }

                                context.DitailsSet.Add(details);
                                context.SaveChanges();
                            }

                            Response.Redirect("Default.aspx");
                        }
                    }
                }
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                context = new ContextModelEntity();
                if (context.StoreKeeperSet != null)
                {
                    var kepper = context.StoreKeeperSet;
                    _table = new DataTable();
                    _table.Columns.Add("Name", typeof(string));
                    _table.Columns.Add(("Quantity"), typeof(int));
                    foreach (var itemKeeper in kepper)
                    {
                        context.DitailsSet.Load();
                        if (context.DitailsSet != null)
                        {
                            var deteils = context.DitailsSet;

                            int sumDetails = 0;
                            foreach (var itemDetails in deteils)
                            {
                                if (itemDetails.StoreKeeper == itemKeeper.Id && itemDetails.DateDelete == null)
                                {
                                    sumDetails += Convert.ToInt32(itemDetails.Quantity);
                                }
                            }
                            DropDownList1.Items.Add(itemKeeper.LastFierstName);
                            DataRow myrow = _table.NewRow();
                            myrow["Name"]     = itemKeeper.LastFierstName;
                            myrow["Quantity"] = sumDetails;
                            _table.Rows.Add(myrow);
                        }
                    }

                    GridView1.DataSource = _table;
                    GridView1.DataBind();
                }
            }
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
                {
                    Path = "~/script/jquery-1.7.2.min.js",
                });
                context = new ContextModelEntity();
                if (context.DitailsSet != null)
                {
                    var details = context.DitailsSet;
                    _table = new DataTable();
                    _table.Columns.Add("NameIdCode", typeof(string));
                    _table.Columns.Add(("NameDetails"), typeof(string));
                    _table.Columns.Add(("Quantity"), typeof(int));
                    _table.Columns.Add(("NameStoreKeeper"), typeof(string));
                    _table.Columns.Add(("DateAdd"), typeof(string));
                    _table.Columns.Add(("DateDelete"), typeof(string));
                    foreach (var valueDetail in details)
                    {
                        DataRow myrow = _table.NewRow();
                        myrow["NameIdCode"]  = valueDetail.NameIdCode;
                        myrow["NameDetails"] = valueDetail.NameDetails;
                        myrow["Quantity"]    = valueDetail.Quantity;
                        myrow["DateAdd"]     = valueDetail.DateAdd;
                        myrow["DateDelete"]  = valueDetail.DateDelete;

                        context.StoreKeeperSet.Load();
                        if (context.StoreKeeperSet != null)
                        {
                            var deteils = context.StoreKeeperSet;


                            foreach (var itemDetails in deteils)
                            {
                                if (valueDetail.StoreKeeper == itemDetails.Id)
                                {
                                    myrow["NameStoreKeeper"] = itemDetails.LastFierstName;
                                }
                            }

                            _table.Rows.Add(myrow);
                        }
                    }

                    DropDownList1.Items.Clear();
                    DropDownList1.Items.Add("Выберите кладовщика");
                    DropDownList1.SelectedIndex = 0;
                    if (context.StoreKeeperSet != null)
                    {
                        foreach (var itemKeeper in context.StoreKeeperSet)
                        {
                            DropDownList1.Items.Add(itemKeeper.LastFierstName);
                        }
                    }



                    GridView1.DataSource = _table;
                    GridView1.DataBind();
                }
            }
            else
            {
                Label1.Text = DropDownList1.SelectedValue.ToString() == "Выберите кладовщика"
                    ? "Выберните кладовщика"
                    : "";


                Label2.Text = Request.Form[TextBox4.UniqueID] == "" ? "Выберите дату" : "";

                // Label3.Text = Request.Form[TextBox5.UniqueID] != "" ? "Выберите дату" : "";
            }
        }