protected void AddButton_Click(object sender, EventArgs e) { try { if (txtName.Text != "") { if (txtStoreOfQty.Text != "") { Shelfs _Shelfs = new Shelfs(); _Shelfs.Name = txtName.Text; _Shelfs.StoreQty = Convert.ToInt32(txtStoreOfQty.Text); decimal AlreadyExistShelfs = _ShelfRepository.AlreadyExistName(_Shelfs); if (AlreadyExistShelfs >= 1) { lblmsg.Text = "This Shelfs Already Here!!...."; lblmsg.ForeColor = Color.Red; txtName.Focus(); } else { int Savesuccess = _ShelfRepository.Add(_Shelfs); if (Savesuccess > 0) { lblmsg.Text = "This Shelfs Save Successefully!!...."; lblmsg.ForeColor = Color.Green; LoadShelfs(); txtStoreOfQty.Text = ""; txtName.Text = ""; //Response.Redirect(Request.Url.AbsoluteUri); } else { lblmsg.Text = "This Shelfs Saving Failed!!...."; lblmsg.ForeColor = Color.Red; } } } else { txtStoreOfQty.Focus(); lblmsg.Text = "Please Type Shelfs Store Qty"; lblmsg.ForeColor = Color.Red; } } else { txtName.Focus(); lblmsg.Text = "Please Type Shelfs Name"; lblmsg.ForeColor = Color.Red; } } catch (Exception ex) { lblmsg.Text = ex.Message; lblmsg.ForeColor = Color.Red; } }
public Shelfs GetQtyByShelfs(int Id) { Shelfs _Shelfs = null; string query = ("Select *From Shelfs where Id='" + Id + "' "); var reader = _MainRepository.Reader(query, _MainRepository.ConnectionString()); if (reader.HasRows) { reader.Read(); _Shelfs = new Shelfs(); _Shelfs.StoreQty = Convert.ToInt32(reader["StoreQty"].ToString()); } reader.Close(); return(_Shelfs); }
public List <Shelfs> GetAll() { var _ShelfList = new List <Shelfs>(); string query = ("Select *From Shelfs"); var reader = _MainRepository.Reader(query, _MainRepository.ConnectionString()); if (reader.HasRows) { while (reader.Read()) { var _Shelfs = new Shelfs(); _Shelfs.Name = reader["Name"].ToString(); _Shelfs.StoreQty = Convert.ToInt32(reader["StoreQty"].ToString()); _ShelfList.Add(_Shelfs); } } reader.Close(); return(_ShelfList); }
protected void ShelfGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { Shelfs _Shelfs = new Shelfs(); _Shelfs.Name = ShelfGridView.DataKeys[e.RowIndex].Value.ToString(); int deletesuccess = _ShelfRepository.Delete(_Shelfs); if (deletesuccess > 0) { LoadShelfs(); lblmsg.Text = "Successefully Delete Shelfs!!...."; lblmsg.ForeColor = Color.Green; } } catch (Exception ex) { lblmsg.Text = ex.Message; lblmsg.ForeColor = Color.Red; } }
public int Delete(Shelfs _Shelfs) { string query = ("Delete From Shelfs Where Name='" + _Shelfs.Name + "' "); return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString())); }
public int Add(Shelfs _Shelfs) { string query = "Insert Into Shelfs(Name,StoreQty,Date) Values ('" + _Shelfs.Name + "','" + _Shelfs.StoreQty + "','" + DateTime.Now.ToShortDateString() + "')"; return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString())); }
public decimal AlreadyExistName(Shelfs _Shelfs) { string query = "Select Count(*)from Shelfs Where Name='" + _Shelfs.Name + "' "; return(_MainRepository.ExecuteScalar(query, _MainRepository.ConnectionString())); }