Esempio n. 1
0
        public static void Update(Mathang mh)
        {
            using (SqlConnection cnn = ConnectDataBase())
            {
                SqlCommand cmd = new SqlCommand("sp_Mathang_Update", cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@mamh", mh.Mamh);
                cmd.Parameters.AddWithValue("@tenmh", mh.Tenmh);
                cmd.Parameters.AddWithValue("@giaban", mh.Giaban);
                cmd.Parameters.AddWithValue("@giagiam", mh.Giagiam);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception)
                {

                }
            }
        }
Esempio n. 2
0
    protected void grv_mathang_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txttenmh = (TextBox)grv_mathang.Rows[e.RowIndex].Cells[2].Controls[0];
        TextBox txtgiaban = (TextBox)grv_mathang.Rows[e.RowIndex].Cells[4].Controls[0];
        TextBox txtgiagiam = (TextBox)grv_mathang.Rows[e.RowIndex].Cells[5].Controls[0];

        string mamh = grv_mathang.DataKeys[e.RowIndex].Value.ToString();
        Mathang mh = new Mathang();

        mh.Mamh = mamh;
        mh.Tenmh = txttenmh.Text;
        mh.Giaban = decimal.Parse(txtgiaban.Text);
        mh.Giagiam = decimal.Parse(txtgiagiam.Text);

        try
        {
            MathangBUS.Mathang_Update(mh);
            Response.Write("<script>alert('Cập nhật mặt hàng thành công')</script>");
            Response.Redirect(Request.Url.AbsoluteUri);
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message + "')</script>");
        }
    }
Esempio n. 3
0
 public static void Mathang_Update(Mathang mh)
 {
     MathangDAO.Update(mh);
 }
Esempio n. 4
0
    protected void btn_themmathang_Click(object sender, EventArgs e)
    {
        Mathang mh = new Mathang();

        mh.Mamh = txt_mamh.Text;
        mh.Tenmh = txt_tenmh.Text;
        mh.Hinhdd = mh.Mamh + ".jpg";
        mh.Madm = ddl_danhmuc.SelectedValue.ToString();
        mh.Mota = cke_mota.Text;
        mh.Giaban = decimal.Parse(txt_giaban.Text + "000");
        mh.Giagiam = decimal.Parse(txt_giagiam.Text + "000");
        if(ful_anhdaidien.HasFile && txt_tenmh.Text != "" && txt_giaban.Text != "" && txt_giagiam.Text != "" && cke_mota.Text != "")
        {

            FileInfo info = new FileInfo(ful_anhdaidien.FileName);
            if (info.Extension == ".jpg")
            {
                ful_anhdaidien.SaveAs(Server.MapPath("~/images/mat-hang/") + ful_anhdaidien.FileName);
                try
                {
                    File.Move(Server.MapPath("~/images/mat-hang/") + info.Name, Server.MapPath("~/images/mat-hang/") + mh.Hinhdd);
                }
                catch (Exception)
                {

                }

                try
                {
                    MathangBUS.Mathang_Insert(mh);
                    List<string> ds_size = new List<string>();
                    if(ddl_danhmuc.SelectedValue=="AO")
                    {
                        if(size_S.Checked==true)
                        {
                            ds_size.Add("S");
                        }
                        if (size_M.Checked == true)
                        {
                            ds_size.Add("M");
                        }
                        if (size_L.Checked == true)
                        {
                            ds_size.Add("L");
                        }
                        if (size_XL.Checked == true)
                        {
                            ds_size.Add("XL");
                        }
                    }
                    else if(ddl_danhmuc.SelectedValue=="QU")
                    {
                        if (size_30.Checked == true)
                        {
                            ds_size.Add("30");
                        }
                        if (size_31.Checked == true)
                        {
                            ds_size.Add("31");
                        }
                        if (size_32.Checked == true)
                        {
                            ds_size.Add("32");
                        }
                        if (size_33.Checked == true)
                        {
                            ds_size.Add("33");
                        }
                        if (size_34.Checked == true)
                        {
                            ds_size.Add("34");
                        }
                    }
                    else if(ddl_danhmuc.SelectedValue=="GD")
                    {
                        if (size_40.Checked == true)
                        {
                            ds_size.Add("40");
                        }
                        if (size_41.Checked == true)
                        {
                            ds_size.Add("41");
                        }
                        if (size_42.Checked == true)
                        {
                            ds_size.Add("42");
                        }
                        if (size_43.Checked == true)
                        {
                            ds_size.Add("43");
                        }
                        if (size_44.Checked == true)
                        {
                            ds_size.Add("44");
                        }
                    }
                    else
                    {

                    }

                    foreach (string i in ds_size)
                    {
                        SizeBUS.Size_Insert(mh.Mamh, i);
                    }
                    Response.Redirect(Request.Url.AbsoluteUri);
                    Response.Write("<script>alert('Thêm mặt hàng thành công')</script>");
                    Mathang_Show();
                }
                catch (Exception ex)
                {
                    Response.Write("<script>alert('" + ex.Message + "')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('Định dạng ảnh phải là JPEG(*.jpg)')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('Bạn chưa nhập đầy đủ thông tin')</script>");
        }
    }
Esempio n. 5
0
 public static void Mathang_Insert(Mathang mh)
 {
     MathangDAO.Insert(mh);
 }