Esempio n. 1
0
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        try
        {
            if (Common.LoaiNguoiDungID() == 3)
            {
                NhomSanPham nhomsanpham = new NhomSanPham();
                if (Request.QueryString["subid"] == null)
                {
                    nhomsanpham.InsertFields(txtTenNhomCon.Text, null, Convert.ToInt32(Request.QueryString["id"]), false,
                                             Convert.ToInt32(txtThuTu.Text), null, null, null, null, null, null);
                }
                else
                {
                    nhomsanpham.UpdateFields(Convert.ToInt32(Request.QueryString["subid"]), txtTenNhomCon.Text, null,
                                             Convert.ToInt32(Request.QueryString["id"]), null,
                                             Convert.ToInt32(txtThuTu.Text), null, null, null, null, null, null);
                }
            }
            else if (Common.LoaiNguoiDungID()==2)
            {
                NhomSanPhamCuaHang nhomsanpham = new NhomSanPhamCuaHang();
                CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham();
                if (Request.QueryString["id"] == null)
                {
                    int chnspid = chnsp.InsertFields(int.Parse(CuaHangID), int.Parse(ddlNhomSanPham.SelectedValue), null);
                    nhomsanpham.InsertFields(Convert.ToInt32(Request.QueryString["pid"]), int.Parse(ddlNhomSanPham.SelectedValue)
                        , Convert.ToInt32(txtThuTu.Text), int.Parse(CuaHangID), txtTenNhomCon.Text, chnspid);

                }
                else
                {
                    NhomSanPhamCuaHang nsp = new NhomSanPhamCuaHang();
                    DataSet ds = nsp.SelectByID(int.Parse(Request["id"]));
                    int chnspid = int.Parse("0" + ds.Tables[0].Rows[0]["CuaHangNhomSanPhamID"].ToString());
                    //chnsp.UpdateFields();
                    nhomsanpham.UpdateFields(Convert.ToInt32(Request.QueryString["id"]),
                                             null, int.Parse(ddlNhomSanPham.SelectedValue),
                                             Convert.ToInt32(txtThuTu.Text), null, txtTenNhomCon.Text,null);
                    chnsp.UpdateFields(chnspid,int.Parse(CuaHangID),int.Parse(ddlNhomSanPham.SelectedValue),null);
                }
            }
            string strScript = "<script language='JavaScript'>" + "window.parent.RefreshCat();</script>";
            ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript);
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Esempio n. 2
0
    private void LoadDataForCuaHang(string Id)
    {
        try
        {
            NhomSanPhamCuaHang nhomsanpham = new NhomSanPhamCuaHang();
            DataSet ds = nhomsanpham.SelectByID(Convert.ToInt32(Id));

            if (ds.Tables[0].Rows.Count > 0)
            {
                txtTenNhomCon.Text = ds.Tables[0].Rows[0]["TenNhomSanPham"].ToString();
                txtThuTu.Text = ds.Tables[0].Rows[0]["SapXep"].ToString();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Esempio n. 3
0
 private void deleteNhomSanPhamCuaHang(int id)
 {
     NhomSanPhamCuaHang nsp = new NhomSanPhamCuaHang();
     DataSet ds = nsp.SelectByID(id);
     if (ds.Tables[0].Rows.Count > 0)
     {
         CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham();
         chnsp.Delete(int.Parse(ds.Tables[0].Rows[0]["CuaHangNhomSanPhamID"].ToString()));
     }
     nsp.Delete(id);
 }