protected void btnSave_Click(object sender, EventArgs e) { CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham(); for(int i = 0; i< grvNhomSanPham.Rows.Count; i++ ) { TextBox txt = (TextBox) grvNhomSanPham.Rows[i].Cells[2].FindControl("txtDisplayName"); if (txt != null) chnsp.UpdateFields(int.Parse(grvNhomSanPham.DataKeys[i].Value.ToString()), null, null, txt.Text); } }
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()); } }
protected void btnSave_Click(object sender, EventArgs e) { //int firstCatId = 0; foreach (UltraGridRow row in grdCat.Rows) { //int id = int.Parse(row.Cells.FromKey("NhomSanPhamID").Value.ToString()); int NhomSanPhamID = 0; CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham(); if (row.Cells.FromKey("Selected").Value != null) { if (bool.Parse(row.Cells.FromKey("Selected").Value.ToString())) { NhomSanPhamID = int.Parse(row.Cells.FromKey("NhomSanPhamID").Value.ToString()); chnsp.InsertFields(CuaHangID, NhomSanPhamID, null); } } } string strScript = "<script language='JavaScript'>" + "window.parent.Refresh();</script>"; ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript); }
private bool checkNhomSanPham(int NhomSanPhamID, int CuaHangID) { CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham(); DataSet ds = chnsp.SelectByNhomSanPhamCuaHangID(CuaHangID, NhomSanPhamID); if (ds.Tables[0].Rows.Count > 0) return true; else return false; }
private void AddNhomSanPhamToCuaHang(int NhomSanPhamID, int CuaHangID) { CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham(); DataSet dschnsp = chnsp.SelectByNhomSanPhamCuaHangID(CuaHangID, NhomSanPhamID); if (dschnsp.Tables[0].Rows.Count <= 0) { chnsp.Insert(CuaHangID, NhomSanPhamID, ""); NhomSanPham nsp = new NhomSanPham(); DataSet ds = nsp.SelectByID(NhomSanPhamID); int NhomChaID = int.Parse(ds.Tables[0].Rows[0]["NhomChaID"].ToString()); if (NhomChaID != 0) AddNhomSanPhamToCuaHang(NhomChaID, CuaHangID); } }
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); }
private void deleteCuaHangNhomSanPham(int id) { CuaHangNhomSanPham chnsp = new CuaHangNhomSanPham(); chnsp.DeleteAllByCuaHangNhomSanPhamID(id); }