private void addbutton_Click(object sender, EventArgs e) { try { if (categorynametextBox.Text.Length > 0 ) { Store aStore = new Store(); aStore.ItemName = categorynametextBox.Text; StoreDAO aStoreDao = new StoreDAO(); string sr = aStoreDao.InsertOtherCategory(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } } else MessageBox.Show("Please Check Input"); } catch (Exception) { MessageBox.Show("Please Check Input"); } }
public List<Store> GetAllOtherStore() { List<Store> aStores = new List<Store>(); try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.GetAllOtherStore)); IDataReader aReader = this.ExecuteReader(sqlComm); if (aReader != null) { while (aReader.Read()) { Store aStore = new Store(); aStore = ReadToStore(aReader); aStores.Add(aStore); } } } catch (Exception) { } return aStores; }
public List<Store> GetAllotherCategory() { List<Store> aStores = new List<Store>(); try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.GetAllotherCategory)); IDataReader aReader = this.ExecuteReader(sqlComm); if (aReader != null) { while (aReader.Read()) { Store aStore = new Store(); aStore.ItemName = aReader["categoryName"].ToString(); aStore.StoreId = Convert.ToInt32(aReader["categoryId"]); aStores.Add(aStore); } } } catch (Exception) { } return aStores; }
private void savebutton_Click(object sender, EventArgs e) { Store aStore = new Store(); StoreDAO aStoreDao = new StoreDAO(); aStore = aStoreDao.GetStoreByItemId(ItemId); Transaction1 aTransaction1 = new Transaction1(); aTransaction1.ItemName = aStore.ItemName; aTransaction1.TransactionType = transactiontypelebel.Text; aTransaction1.Amount = Convert.ToDouble(quantitytextBox.Text)*aStore.UnitPrice; aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text); aTransaction1.ItemUnit = aStore.Unit; aTransaction1.CauseOrPurpose = purposeTextBox.Text.Trim(); aStore.Quantity -= Convert.ToDouble(quantitytextBox.Text); if (aStore.Quantity >= 0) { aStoreDao.InsertTransaction(aTransaction1,CategoryId); string sr = aStoreDao.UpdateStore(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } } else MessageBox.Show("Not Enough quantity"); }
private void savebutton_Click(object sender, EventArgs e) { Store aStore=new Store(); StoreDAO aStoreDao=new StoreDAO(); aStore = aStoreDao.GetOtherStoreByItemId(ItemId); Transaction1 aTransaction1=new Transaction1(); aTransaction1.ItemName = aStore.ItemName; aTransaction1.TransactionType = "Purchase"; aTransaction1.SupplierName = supplierNamecomboBox.Text; aTransaction1.Amount = Convert.ToDouble(amounttextBox.Text); aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text); aTransaction1.ItemUnit = aStore.Unit; aStoreDao.InsertOtherTransaction(aTransaction1,CategoryId); double newstore = aStore.Amount + Convert.ToDouble(amounttextBox.Text); double newquantity = aStore.Quantity + Convert.ToDouble(quantitytextBox.Text); double unitprice = 0; if (newquantity != 0) { unitprice = (newstore / newquantity); } else unitprice = 0; aStore.UnitPrice = unitprice; aStore.Quantity = newquantity; string sr = aStoreDao.UpdateOtherStore(aStore); MessageBox.Show(sr); if(sr=="Insert Sucessfully") { this.Close(); } }
private void addbutton_Click(object sender, EventArgs e) { try { if(itemnametextBox.Text.Length>0 && unitcomboBox.Text.Length>0) { Store aStore=new Store(); aStore.ItemName = itemnametextBox.Text; aStore.Unit = unitcomboBox.Text; aStore.CategoryId = Convert.ToInt32(categorycomboBox.SelectedValue); aStore.CategoryName = categorycomboBox.Text; StoreDAO aStoreDao=new StoreDAO(); string sr = aStoreDao.InsertOtherItem(aStore); MessageBox.Show(sr); if(sr=="Insert Sucessfully") { this.Close(); } } else MessageBox.Show("Please Check Input"); } catch (Exception) { MessageBox.Show("Please Check Input"); } }
private Store ReadToStore(IDataReader aReader) { Store aStore=new Store(); try { aStore.StoreId = Convert.ToInt32(aReader["item_id"]); } catch (Exception) { } try { aStore.ItemName = (aReader["item_name"]).ToString(); } catch (Exception) { } try { aStore.Quantity = Convert.ToDouble(aReader["quantity"]); } catch (Exception) { } try { aStore.Unit = (aReader["item_unit"]).ToString(); } catch (Exception) { } try { aStore.UnitPrice = Convert.ToDouble(aReader["amount"]); } catch (Exception) { } try { aStore.CategoryName = (aReader["categoryname"]).ToString(); } catch (Exception) { } try { aStore.CategoryId = Convert.ToInt32(aReader["categoryid"]); } catch (Exception) { } try { aStore.Amount = aStore.UnitPrice*aStore.Quantity; } catch (Exception) { } aStore.Damage = "Damage"; aStore.StockOut = "StockOut"; aStore.Purchase = "Purchase"; aStore.Delete = "Delete"; aStore.Return = "Return"; return aStore; }
public string UpdateStore(Store aStore) { try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.UpdateStore),aStore.StoreId,aStore.Quantity,aStore.UnitPrice); this.ExecuteNonQuery(sqlComm); return "Insert Sucessfully"; } catch (Exception) { return "Please Try Agian"; } finally { this.CloseConnection(); } }
public string InsertRawmaterialCategory(Store aStore) { try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.InsertRawmaterialCategory), aStore.ItemName); this.ExecuteNonQuery(sqlComm); return "Insert Sucessfully"; } catch (Exception ex) { return "Please try again"; //throw new Exception(ex.ToString()); } finally { this.CloseConnection(); } }
public string InsertOtherItem(Store aStore) { try { DateTime aDateTime = DateTime.Now.Date; this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.InsertOtherItem),aStore.ItemName,aStore.Unit,0,0,aStore.CategoryId,aStore.CategoryName); this.ExecuteNonQuery(sqlComm); return "Insert Sucessfully"; } catch (Exception ex) { return "Please try again"; //throw new Exception(ex.ToString()); } finally { this.CloseConnection(); } }
public Store GetStoreByItemId(int itemId) { Store aStore = new Store(); try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.GetStoreByItemId),itemId); IDataReader aReader = this.ExecuteReader(sqlComm); if (aReader != null) { while (aReader.Read()) { aStore = ReadToStore(aReader); } } } catch (Exception) { } finally { this.CloseConnection(); } return aStore; }