Example #1
0
        protected void GrDelete(object sender, CommandEventArgs e)
        {
            int nPageNumber             = int.Parse(txtPageNumber.Text);
            int nPageSize               = int.Parse(txtPageSize.Text);
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];

            nUserLogin.CheckRole("CU0016");
            if (!nUserLogin.Role.Del)
            {
                Response.Write("<script >alert('Bạn không có quyền xóa danh mục này!')</script>");
            }
            else
            {
                try
                {
                    int mKey = int.Parse(e.CommandArgument.ToString());
                    CooperativePurchasing_Other_Info info = new CooperativePurchasing_Other_Info(mKey);
                    //if ((DateTime.Now - info.Datetime).TotalDays > 7)
                    //{
                    //    Response.Write("<script >alert('Dữ liệu đã quá 7 ngày, không được phép xóa!')</script>");
                    //}
                    //else
                    {
                        info.Delete();
                        DataTable nTable = CooperativePurchasing_Other_Data.GetList(nPageSize, nPageNumber, Session["CooperativeKey"].ToInt());
                        DateTime  dtfrom = DateTime.ParseExact(txtfromDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        DateTime  dtto   = DateTime.ParseExact(txttoDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        if (nTable.Rows.Count == 0)
                        {
                            nTable.Rows.Add("", 0, "", 0, 0, 0, 0, DateTime.Now, "", "", 0);
                        }
                        GV_HarvestedForSale.DataSource = nTable;
                        GV_HarvestedForSale.DataBind();
                        LoadPages();
                    }
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }
Example #2
0
        protected void LoadInfo(int Key)
        {
            CooperativePurchasing_Other_Info info = new CooperativePurchasing_Other_Info(Key);

            if (Key != 0)
            {
                txtDatetime.Text = info.Datetime.ToString("dd/MM/yyyy");
            }
            else
            {
                txtDatetime.Text = DateTime.Now.ToString("dd/MM/yyyy");
            }
            DDLSeeds.SelectedValue    = info.SeedKey.ToString();
            txtcode.Text              = info.Code;
            txtQuantity.Text          = info.Quantity.ToString();
            txtBaskets.Text           = info.Baskets.ToString();
            DDLUnit.SelectedValue     = info.UnitKey.ToString();
            txtMember.Text            = info.Name;
            txtSolution.Text          = info.Solution;
            DDLEvaluate.SelectedValue = info.Evaluate.ToString();
            txtPrice.Text             = info.Price.ToString();
        }
Example #3
0
        protected void SaveInfo()
        {
            if (txtQuantity.Text == "" || (txtQuantity.Text.ToInt() < 1))
            {
                lberr.Text = "Số lượng thu mua không được bé hơn 1";
                return;
            }
            if (txtPrice.Text == "")
            {
                lberr.Text = "Vui lòng kiểm tra giá mua";
                return;
            }
            if (txtBaskets.Text == "" || (txtBaskets.Text.ToInt() < 0))
            {
                lberr.Text = "Số lượng sọt rổ không được bé hơn 0";
                return;
            }
            if (txtPrice.Text == "" || (txtPrice.Text.ToInt() < 0))
            {
                lberr.Text = "Tổng tiền không được bé hơn 0";
                return;
            }
            CooperativePurchasing_Other_Info info = new CooperativePurchasing_Other_Info(txtKey.Text.ToInt());

            info.Baskets        = txtBaskets.Text.ToInt();
            info.Datetime       = DateTime.ParseExact(txtDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            info.Quantity       = txtQuantity.Text.ToInt();
            info.UnitKey        = DDLUnit.SelectedValue.ToInt();
            info.CooperativeKey = Session["CooperativeKey"].ToInt();
            info.Price          = txtPrice.Text.ToInt();
            info.Name           = txtMember.Text;
            info.SeedKey        = DDLSeeds.SelectedValue.ToInt();
            info.Code           = txtcode.Text;
            info.Solution       = txtSolution.Text;
            info.Evaluate       = DDLEvaluate.SelectedValue.ToInt();
            info.Save();
            CloseForm();
        }