예제 #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());
        }
    }
예제 #2
0
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtTenNhomSanPham.Text.Trim() != "")
         {
             if (Common.LoaiNguoiDungID() == 3)
             {
                 NhomSanPham nhomsanpham = new NhomSanPham();
                 if (Request.QueryString["id"] == null)
                 {
                     nhomsanpham.InsertFields(txtTenNhomSanPham.Text, "", 0, false, Convert.ToInt32(txtThuTu.Text), null,
                                              null, null, null, null, null);
                 }
                 else
                 {
                     nhomsanpham.UpdateFields(Convert.ToInt32(Request.QueryString["id"]),
                                              txtTenNhomSanPham.Text, null, null, null, Convert.ToInt32(txtThuTu.Text),
                                              null, null, null, null, null, null);
                 }
                 Cache.Remove("dm1");
             }
             else if (Common.LoaiNguoiDungID() == 2)
             {
                 NhomSanPhamCuaHang nhomsanpham = new NhomSanPhamCuaHang();
                 if (Request.QueryString["id"] == null)
                 {
                     nhomsanpham.InsertFields( 0, 0, int.Parse("0" + txtThuTu.Text),int.Parse(cuahangid),txtTenNhomSanPham.Text,null);
                 }
                 else
                 {
                     nhomsanpham.UpdateFields(Convert.ToInt32(Request.QueryString["id"]),
                                               null, null, int.Parse("0" + txtThuTu.Text), null, txtTenNhomSanPham.Text,null);
                 }
             }
             string strScript = "<script language='JavaScript'>" + "window.parent.RefreshCat();</script>";
             ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript);
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
     }
 }