private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; context.Dispose(); userIdentity.Dispose(); this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { //try //{ PharmacyDbContext db = new PharmacyDbContext(); foreach (ListViewItem item in lvMedicine.Items) { Medicine medicine = new Medicine(); medicine.Name = item.SubItems[2].Text; medicine.Id = UniqueNumber.GenerateUniqueNumber(); medicine.CreatedBy = currentUser; medicine.CreatedDate = DateTime.Now; medicine.GroupId = GroupFactory.GetGroupId(item.SubItems[3].Text, currentUser); medicine.CompanyId = CompanyFactory.GetCompanyId(item.SubItems[4].Text, currentUser); db.Medicine.Add(medicine); } db.SaveChanges(); db.Dispose(); MessageBox.Show(@"Save successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); lvMedicine.Items.Clear(); //} //catch (Exception exception) //{ // MessageBox.Show("Saving Error:" + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //} }
private void btnSave_Click(object sender, EventArgs e) { string expenseType = txtExpenseType.Text; if (expenseType == "") { MessageBox.Show("Expense can't be empty!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } PharmacyDbContext db = new PharmacyDbContext(); ExpenseType expenseTypes = new ExpenseType() { CreatedBy = currentUser, CreatedDate = DateTime.Now, Id = Guid.NewGuid().ToString(), Type = expenseType }; db.ExpenseType.Add(expenseTypes); db.SaveChanges(); db.Dispose(); MessageBox.Show("Save successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); txtExpenseType.Text = ""; }
private void btnTodayDue_Click(object sender, EventArgs e) { DateTime today = DateTime.Today; PharmacyDbContext db = new PharmacyDbContext(); int rowNo = 1; var data = db.Voucher .ToList() .Where(d => d.CreatedDate.Date == today.Date && d.CustomerId != null) .GroupBy(o => o.CustomerId) .Select(x => new { SL = rowNo++, CustomerId = x.Key, CustomerName = x.Select(a => a.Customer.Name).FirstOrDefault(), Mobile = x.Select(a => a.Customer.Mobile).FirstOrDefault(), Due = x.Where(c => c.GLCode == GLCode.AccountReceivable).Sum(a => a.Dr - a.Cr) < 0 ? 0 : x.Where(c => c.GLCode == GLCode.AccountReceivable).Sum(a => a.Dr - a.Cr), Paid = x.Where(c => c.GLCode == GLCode.Cash).Sum(a => a.Dr), TotalSale = x.Where(c => c.GLCode == GLCode.SaleMedicine).Sum(a => a.Cr), Date = x.Select(a => a.CreatedDate).FirstOrDefault().ToString("d") }).ToList(); db.Dispose(); dgvDue.Columns.Clear(); dgvDue.DataSource = data; lblDueTotal.Text = data.Sum(x => x.Due).ToString(); // db.Voucher.Where(a => a.GLCode == GLCode.AccountReceivable && a.CustomerId != null).ToList().Sum(x => x.Dr-x.Cr).ToString(); lblPaidTotal.Text = data.Sum(x => x.Paid).ToString(); //db.Voucher.Where(a=>a.GLCode == GLCode.Cash && a.CustomerId != null).ToList().Sum(x => x.Dr).ToString(); lblTotal.Text = data.Sum(x => x.TotalSale).ToString(); AddButton(); MakeFullWidthScreen(); }
private string GetGroup(string id) { PharmacyDbContext db = new PharmacyDbContext(); string name = db.Groups.Where(g => g.Id == id).Select(s => s.Name).FirstOrDefault(); db.Dispose(); return(name); }
private string GetMedicineName(string id) { PharmacyDbContext db = new PharmacyDbContext(); string name = db.Medicine.Where(s => s.Id == id).Select(a => a.Name).FirstOrDefault(); db.Dispose(); return(name); }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
private void btnPay_Click(object sender, EventArgs e) { PharmacyDbContext db = new PharmacyDbContext(); SaveInvoice(db); db.SaveChanges(); db.Dispose(); MessageBox.Show("Save successful", "Paid!", MessageBoxButtons.OK, MessageBoxIcon.Hand); }
private void SetLabelValue() { PharmacyDbContext db = new PharmacyDbContext(); lblMedicine.Text = db.Medicine.Count().ToString(); lblGroup.Text = db.Groups.Count().ToString(); lblcompany.Text = db.Company.Count().ToString(); db.Dispose(); }
public SaveMedicine(string currentUser) { this.currentUser = currentUser; InitializeComponent(); PharmacyDbContext db = new PharmacyDbContext(); GetAutocompleteForCompany(db); GetAutocompleteForGroup(db); db.Dispose(); }
public Salemedicine(string user) { currentUser = user; InitializeComponent(); PharmacyDbContext db = new PharmacyDbContext(); GetAutocompleteForMedicine(db); GetAutocompleteForCustomer(db); db.Dispose(); }
private decimal GetPurchaseMedicine(string medicineId) { PharmacyDbContext db = new PharmacyDbContext(); var count = db.PurchaseSub.Where(m => m.MedicinId == medicineId) .ToList() .Sum(x => x.Quantity); db.Dispose(); return(count); }
public void TearDown() { dbContext.InvoiceContents.RemoveRange(dbContext.InvoiceContents); dbContext.Invoices.RemoveRange(dbContext.Invoices); dbContext.Users.RemoveRange(dbContext.Users); dbContext.Medications.RemoveRange(dbContext.Medications); dbContext.SaveChanges(); dbContext.Dispose(); }
private void UpdateUnitPrice(string medicineName, string rate, DateTime exDate) { PharmacyDbContext db = new PharmacyDbContext(); decimal price = Convert.ToDecimal(rate); Medicine medicine = db.Medicine.FirstOrDefault(x => x.Name == medicineName); medicine.UnitPrice = price; medicine.ExpiredDate = exDate; db.SaveChanges(); db.Dispose(); }
private void btnSubmit_click(object sender, EventArgs e) { PharmacyDbContext db = new PharmacyDbContext(); SaveInvoice(db); db.SaveChanges(); db.Dispose(); MessageBox.Show("Save successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearFields(); }
private void btnSubmit_click(object sender, EventArgs e) { PharmacyDbContext db = new PharmacyDbContext(); SaveInvoice(db); db.SaveChanges(); db.Dispose(); MessageBox.Show("Save successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); btnPrint.Enabled = true; txtNote.Text = ""; lvExpense.Items.Clear(); }
public PurchaseMedicine(string user) { currentUser = user; InitializeComponent(); PharmacyDbContext db = new PharmacyDbContext(); GetAutocompleteForMedicine(db); GetAutocompleteForSupplier(db); GetAutocompleteForCompany(db); GetAutocompleteForGroup(db); db.Dispose(); }
private bool IsMedicineExest(string medicine) { bool isExit = false; PharmacyDbContext db = new PharmacyDbContext(); Medicine med = db.Medicine.ToList().FirstOrDefault(x => x.Name == medicine); if (med != null) { isExit = true; } db.Dispose(); return(isExit); }
private void btnSubmit_click(object sender, EventArgs e) { PharmacyDbContext db = new PharmacyDbContext(); SaveInvoice(db); db.SaveChanges(); db.Dispose(); MessageBox.Show("Save successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); lvPurchaseMedicine.Items.Clear(); txtDiscount.Text = ""; txtDue.Text = ""; txtPaid.Text = ""; txtNote.Text = ""; }
private void frmNewUser_Load(object sender, EventArgs e) { lstRoles = context.Roles.Select(r => r.Name)?.ToList(); if (lstRoles != null) { cmbRole.Properties.Items.AddRange(lstRoles); cmbRole.Text = lstRoles[0]; } else { XtraMessageBox.Show("There are no role in database", "Error"); context.Dispose(); userIdentity.Dispose(); this.Close(); } }
public saveExpense(string user) { currentUser = user; InitializeComponent(); PharmacyDbContext db = new PharmacyDbContext(); List <ExpenseType> types = db.ExpenseType.ToList(); ExpenseType first = new ExpenseType { Id = "0", Type = "-- select one --" }; types.Insert(0, first); cbExpenseType.DataSource = types; cbExpenseType.DisplayMember = "Type"; // types.Select(o => o.Type).ToString(); cbExpenseType.ValueMember = "Id"; // types.Select(o => o.Id).ToString(); db.Dispose(); }
private void DateRangeExpense() { DateTime sdate = Convert.ToDateTime(dtpStartDate.Text); DateTime edate = Convert.ToDateTime(dtpEndDate.Text); List <PurchaseList> list = new List <PurchaseList>(); PharmacyDbContext db = new PharmacyDbContext(); int rowNo = 1; var data = db.PurchaseSub .Where(a => a.CreatedDate >= sdate && a.CreatedDate <= edate) .ToList() .Select(x => new { SL = rowNo++, x.MedicinId, x.Quantity, x.UnitPrice, x.Total, Date = x.CreatedDate.ToString("d") }).ToList(); foreach (var item in data) { PurchaseList l = new PurchaseList { SL = item.SL.ToString(), MedicineName = GetMedicineName(item.MedicinId), Quantity = item.Quantity, UnitPrice = item.UnitPrice, Total = item.Total, Date = item.Date }; list.Add(l); } lblDueTotal.Text = db.PurchaseSub .ToList() .Where(a => a.CreatedDate >= sdate && a.CreatedDate <= edate) .Sum(x => x.Total).ToString(); // db.Voucher.Where(a => a.GLCode == GLCode.AccountReceivable && a.CustomerId != null).ToList().Sum(x => x.Dr-x.Cr).ToString(); // db.Voucher.Where(a => a.GLCode == GLCode.SaleMedicine && a.CustomerId != null).ToList().Sum(x => x.Cr).ToString(); db.Dispose(); dgvExpense.Columns.Clear(); dgvExpense.DataSource = list; MakeFullWidthScreen(); }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } // Dispose of managed resources here. if (disposing) { if (_disposeContext) { context?.Dispose(); } } // Dispose of any unmanaged resources not wrapped in safe handles. _disposed = true; }
private IEnumerable <Store> MedicineStore() { PharmacyDbContext db = new PharmacyDbContext(); var data = db.Medicine .OrderByDescending(o => o.ExpiredDate) .Include(s => s.Groups) .Include(i => i.Company) .ToList() .GroupBy(g => g.Id) .Select(s => new { Id = s.Key, MedicineName = s.Select(a => a.Name).FirstOrDefault(), Type = s.Select(a => a.MedicineType).FirstOrDefault(), ExpiredDate = s.Select(a => a.ExpiredDate).FirstOrDefault(), Group = s.Select(a => a.GroupId).FirstOrDefault(), Company = s.Select(a => a.Company.Name).FirstOrDefault(), Purchased = s.Sum(a => a.PurchaseSub.Sum(x => x.Quantity)), Sale = s.Sum(a => a.SaleSub.Sum(x => x.Quantity)), Balance = s.Sum(a => a.PurchaseSub.Sum(x => x.Quantity)) - s.Sum(a => a.SaleSub.Sum(x => x.Quantity)) }) .ToList(); List <Store> storages = new List <Store>(); foreach (var item in data) { Store store = new Store(); store.Id = item.Id; store.Name = item.MedicineName; store.Company = item.Company; store.ExpiredDate = item.ExpiredDate; store.GroupName = GetGroup(item.Group); store.Purchased = GetPurchaseMedicine(item.Id); store.Sold = GetSaleMedicine(item.Id); store.Balance = store.Purchased - store.Sold; storages.Add(store); } db.Dispose(); return(storages); }
private void FixedDateExpense() { DateTime date = Convert.ToDateTime(dtpStartDate.Text); PharmacyDbContext db = new PharmacyDbContext(); int rowNo = 1; var data = db.ExpenseMain .ToList() .Where(d => d.CreatedDate.Date == date.Date) .Select(x => new { SL = rowNo++, Id = x.Id, Amount = x.TotalAmount, Date = x.CreatedDate }).ToList(); db.Dispose(); dgvExpense.Columns.Clear(); dgvExpense.DataSource = data; AddButton(); MakeFullWidthScreen(); }
private void ShowData() { PharmacyDbContext db = new PharmacyDbContext(); int rowNo = 1; var data = db.ExpenseMain .ToList() .Select(x => new { SL = rowNo++, Id = x.Id, Amount = x.TotalAmount, Date = x.CreatedDate }).ToList(); lblDueTotal.Text = data.Sum(x => x.Amount).ToString(); // db.Voucher.Where(a => a.GLCode == GLCode.AccountReceivable && a.CustomerId != null).ToList().Sum(x => x.Dr-x.Cr).ToString(); // db.Voucher.Where(a => a.GLCode == GLCode.SaleMedicine && a.CustomerId != null).ToList().Sum(x => x.Cr).ToString(); db.Dispose(); dgvExpense.Columns.Clear(); dgvExpense.DataSource = data; AddButton(); MakeFullWidthScreen(); }
private void ShowData() { PharmacyDbContext db = new PharmacyDbContext(); int rowNo = 1; var data = db.PurchaseSub .ToList() .Select(x => new { SL = rowNo++, x.Id, x.MedicinId, x.Quantity, x.UnitPrice, x.Total, Date = x.CreatedDate.ToString("d") }).ToList(); List <PurchaseList> list = data.Select(item => new PurchaseList { SL = item.SL.ToString(), Id = item.Id, MedicineName = GetMedicineName(item.MedicinId), Quantity = item.Quantity, UnitPrice = item.UnitPrice, Total = item.Total, Date = item.Date }).ToList(); lblDueTotal.Text = db.PurchaseSub.Sum(x => x.Total).ToString(CultureInfo.CurrentCulture); // db.Voucher.Where(a => a.GLCode == GLCode.AccountReceivable && a.CustomerId != null).ToList().Sum(x => x.Dr-x.Cr).ToString(); // db.Voucher.Where(a => a.GLCode == GLCode.SaleMedicine && a.CustomerId != null).ToList().Sum(x => x.Cr).ToString(); db.Dispose(); dgvExpense.Columns.Clear(); dgvExpense.DataSource = list; dgvExpense.Columns[1].Visible = false; MakeFullWidthScreen(); AddButton(); }