public void Save(UserBrand UserBrand) { using (DbManager db = new DbManager()) { if (UserBrand.RecordNumber > 0) { Accessor.Query.Update(db, UserBrand); } else { Accessor.Query.Insert(db, UserBrand); } } }
protected void btnAssign_Click(object sender, EventArgs e) { UserBrand UserBrand = new UserBrand(); if (hfUserBrandId.Value != "0") { UserBrand.RecordNumber = int.Parse(hfUserBrandId.Value); } if (checkAll.Checked == true) { UserBrand.BrandName = "ALL"; } else { UserBrand.BrandName = ddListBrands.SelectedValue; } UserBrand.UserId = int.Parse(gvUsers.SelectedRow.Cells[1].Text); UserBrand.DateRecorded = DateTime.UtcNow; UBM.Save(UserBrand); lblSuccessSaved_ModalPopupExtender.Show(); }
protected void gvUsers_SelectedIndexChanged(object sender, EventArgs e) { int userId = 0; userId = int.Parse(gvUsers.SelectedRow.Cells[1].Text); UB = UBM.GetUserBrandByUserId(userId); if (UB != null) { lblAssignedbrand.Text = "CURENT BRAND: "+UB.BrandName; checkReAssignBrand.Visible = true; ddListBrands.Enabled = false; checkAll.Enabled = false; hfUserBrandId.Value = UB.RecordNumber.ToString(); } else { lblAssignedbrand.Text = "NO ASSIGN BRAND"; checkReAssignBrand.Visible = false; ddListBrands.Enabled = true; checkAll.Enabled = true; hfUserBrandId.Value ="0"; } lblUser.Text ="User Name: "+ gvUsers.SelectedRow.Cells[2].Text; }