public int CreateExpenseCategory(int rootId, int childId, string name, string code, string description) { if (_posManagementDb == null) { _posManagementDb = new PosManagementDbContext(); } ExpenseCategory expenseCategory = new ExpenseCategory(); expenseCategory.RootId = rootId; expenseCategory.ChildId = childId; expenseCategory.Name = name; expenseCategory.Code = code; expenseCategory.Description = description; _posManagementDb.ExpenseCategories.Add(expenseCategory); int rowAffected = _posManagementDb.SaveChanges(); if (rowAffected > 0) { return(rowAffected); } return(0); }
private void itemsDataGridView_DoubleClick(object sender, EventArgs e) { var db = new PosManagementDbContext(); DataGridViewCell cell = null; foreach (DataGridViewCell selectedCell in itemsDataGridView.SelectedCells) { cell = selectedCell; break; } if (cell != null) { DataGridViewRow row = cell.OwningRow; nameTextBox.Text = row.Cells[1].Value.ToString(); //byte[] logoa = (byte[])orgLogo; ////MemoryStream imgbit = new MemoryStream(logoa); //barCodePictureBox.Image = Image.FromStream(imgbit); imgPictureBox.Visible = false; codeTextBox.Visible = true; codeTextBox.Text = row.Cells[4].Value.ToString(); costPriceTextBox.Text = row.Cells[2].Value.ToString(); salePriceTextBox.Text = row.Cells[3].Value.ToString(); descriptionTextBox.Text = row.Cells[6].Value.ToString(); } }
private void saveButton_Click(object sender, EventArgs e) { int id; bool result = int.TryParse(organizationComboBox.SelectedValue.ToString(), out id); //outlet.Code = barCodePictureBox.Text; //outlet.Address = addressTextBox.Text; //outlet.OrganizationId = id; if (db == null) { db = new PosManagementDbContext(); } try { if (db.Outlets.Count(c => c.ContactNo == contactNoTextBox.Text) > 0) { MessageBox.Show("Please Check your Contact No"); return; } else if (db.Outlets.Count(c => c.Code == codeTextBox.Text) > 0) { MessageBox.Show("Please Check your Code"); return; } else if (db.Outlets.Count(c => c.Name == nameTextBox.Text) > 0) { MessageBox.Show("Please Check yourName"); return; } outlet = new Outlet(); outlet.ContactNo = contactNoTextBox.Text; outlet.Name = nameTextBox.Text; outlet.Address = addressTextBox.Text; outlet.OrganizationId = id; outlet.Logo = outletLogo; outlet.Code = GetBarCode(); db.Outlets.Add(outlet); var check = db.SaveChanges(); if (check > 0) { MessageBox.Show("Outlet Saved!"); GetOutlets(); } else { MessageBox.Show("Outlet Not Saved!"); } } catch (Exception) { MessageBox.Show("Please check your input"); } }
private void textBox1_TextChanged(object sender, EventArgs e) { var db = new PosManagementDbContext(); string searchText = textBox1.Text; var organizationInfo = (from exItem in db.ExpenseItems where (exItem.Name.Contains(searchText) || exItem.Code.Contains(searchText)) select exItem).ToList(); expenseCategoryDataGridView.DataSource = organizationInfo; }
private void textBox1_TextChanged(object sender, EventArgs e) { var db = new PosManagementDbContext(); string searchText = textBox1.Text; var organizationInfo = (from item1 in db.ProductItems where (item1.Name.Contains(searchText) || item1.Code.Contains(searchText)) select item1).ToList(); itemsDataGridView.DataSource = organizationInfo; }
private void saveButton_Click(object sender, EventArgs e) { int id; bool result = int.TryParse(itemCategoryComboBox.SelectedValue.ToString(), out id); if (db == null) { db = new PosManagementDbContext(); } try { if (db.ProductItems.Count(c => c.Name == nameTextBox.Text) > 0) { MessageBox.Show("Please Check your Name"); return; } else if (db.ProductItems.Count(c => c.Code == codeTextBox.Text) > 0) { MessageBox.Show("Please Check Your Code"); return; } item = new ProductItem(); item.Name = nameTextBox.Text; item.ItemCategoryId = id; item.Image = itemImage; item.Description = descriptionTextBox.Text; item.CostPrice = Convert.ToDecimal(costPriceTextBox.Text); item.SalePrice = Convert.ToDecimal(salePriceTextBox.Text); Random number = new Random(); item.Code = number.Next(100, 200).ToString(); Zen.Barcode.Code128BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum; barCodePictureBox.Image = barcode.Draw(item.Code, 14); db.ProductItems.Add(item); var check = db.SaveChanges(); if (check > 0) { MessageBox.Show(" Saved! "); GetAllItems(); } else { MessageBox.Show(" Not Saved! "); } } catch (Exception) { MessageBox.Show("Please check your input"); } }
public bool CreateExpenseItem(string name, string code, string description, int expenseCategoryId) { if (posManagementDb == null) { posManagementDb = new PosManagementDbContext(); } ExpenseItem expenseItem = new ExpenseItem(); expenseItem.Name = name; expenseItem.Code = code; expenseItem.Description = description; expenseItem.ExpenseCategoryId = expenseCategoryId; posManagementDb.ExpenseItems.Add(expenseItem); return(true); }
private void updateButton_Click(object sender, EventArgs e) { int y = Convert.ToInt32(expenseCategoryDataGridView.CurrentRow.Cells["Id"].Value); var db = new PosManagementDbContext(); var b = db.ExpenseItems.FirstOrDefault(c => c.Id == y); b.Name = nameTextBox.Text; b.Description = descriptionTextBox.Text; b.Code = codeTextBox.Text; bool update = db.SaveChanges() > 0; if (update) { MessageBox.Show("update"); } else { MessageBox.Show("not updated"); } }
private void expenseCategoryDataGridView_DoubleClick(object sender, EventArgs e) { var db = new PosManagementDbContext(); DataGridViewCell cell = null; foreach (DataGridViewCell selectedCell in expenseCategoryDataGridView.SelectedCells) { cell = selectedCell; break; } if (cell != null) { DataGridViewRow row = cell.OwningRow; nameTextBox.Text = row.Cells[1].Value.ToString(); codeTextBox.Visible = true; barCodePictureBox.Visible = false; codeTextBox.Text = row.Cells[2].Value.ToString(); descriptionTextBox.Text = row.Cells[3].Value.ToString(); gvId = expenseCategoryDataGridView.CurrentRow.Index; } }
private void updateButton_Click(object sender, EventArgs e) { int y = Convert.ToInt32(itemsDataGridView.CurrentRow.Cells["Id"].Value); var db = new PosManagementDbContext(); var b = db.ProductItems.FirstOrDefault(c => c.Id == y); b.Name = nameTextBox.Text; b.Code = codeTextBox.Text; b.CostPrice = Convert.ToDecimal(costPriceTextBox.Text); b.SalePrice = Convert.ToDecimal(codeTextBox.Text); b.Image = itemImage; bool update = db.SaveChanges() > 0; if (update) { MessageBox.Show("update"); } else { MessageBox.Show("not updated"); } }
private void GetOrganizations() { db = new PosManagementDbContext(); var organizationInfo = db.Organizations.ToList(); orgDataGridView.DataSource = organizationInfo;
private void saveButton_Click(object sender, EventArgs e) { if (db == null) { db = new PosManagementDbContext(); } int outletId; bool result = int.TryParse(outletComboBox.SelectedValue.ToString(), out outletId); try { if (db.Parties.Count(c => c.Name == nameTextBox.Text) > 0) { MessageBox.Show("Please Check yourName"); return; } else if (db.Parties.Count(c => c.ContactNo == mobNoTextBox.Text) > 0) { MessageBox.Show("Please Check your ContactNo"); return; } else if (db.Parties.Count(c => c.Code == textBox1.Text) > 0) { MessageBox.Show("Please Check your Code"); return; } aParty.Name = nameTextBox.Text; aParty.ContactNo = mobNoTextBox.Text; aParty.Address = addressTextBox.Text; aParty.Img = orgLogo; aParty.Email = emailTextBox.Text; // aParty.PartyType = partyType; aParty.IsDeleted = false; aParty.Customer = customer; aParty.Supplier = supplier; aParty.OrganizationId = organizationId; aParty.OutletId = outletId; aParty.Code = GetBarCode(); //org.Organizations.Add(aOrganization); db.Parties.Add(aParty); var check = db.SaveChanges(); if (check > 0) { MessageBox.Show("Party Saved!"); } else { MessageBox.Show("Party Not Saved!"); } GetPartyTable(); } catch (Exception) { MessageBox.Show("Please check your input"); } }