public static ResultSet CRUD(Customers cus, Cate cate, Products pro, Orders ord, Signin sign, EntityState state, string table) { ResultSet r = new ResultSet(); try { switch (table) { case "customer": r = HelperCustomer.CRUD(cus, state); break; case "category": r = HelperCate.CRUD(cate, state); break; case "product": r = HelperProduct.CRUD(pro, state); break; case "order": r = HelperOrder.CRUD(ord, state); break; case "signin": r = HelperSignin.CRUD(sign, state); break; default: break; } if (r.Message != null) { MessageBox.Show(r.Message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } return(r); } catch (Exception e) { r.Message = e.Message; } return(r); }
private void BtEditCate_Click(object sender, EventArgs e) { var ct = HelperCate.GetCate(cateID); if (ct != null) { int c = 0; if (!Helper.I(tbCateName1.Text)) { ct.cateName = tbCateName1.Text; c++; } if (!Helper.I(tbExp1.Text)) { ct.explanation = tbExp1.Text; c++; } r = Helper.CRUD(null, ct, null, null, null, EntityState.Modified, "category"); if (r.isSuccess) { tbCateName1.Clear(); tbExp1.Clear(); DisplayCategories(); DisplayProducts(); DisplayOrders(); ComboBoxCateSources(); if (c != 0) { MessageBox.Show("Kategori güncellendi!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } gbEditCate.Enabled = false; }
void DisplayCategories() { dgvCategories.Rows.Clear(); foreach (var item in HelperCate.GetCateList()) { dgvCategories.Rows.Add(item.cateName, item.explanation); } }
private void BtRowEditCate_Click(object sender, EventArgs e) { var ct = HelperCate.GetCate(cateID); if (ct != null) { gbEditCate.Enabled = true; tbCateName1.Clear(); tbExp1.Clear(); } }
private void DgvCategories_CellClick(object sender, DataGridViewCellEventArgs e) { string categoryName = null, explanation = null; if (dgvCategories.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { dgvCategories.CurrentRow.Selected = true; categoryName = dgvCategories.Rows[e.RowIndex].Cells["categoryName"].FormattedValue.ToString(); explanation = dgvCategories.Rows[e.RowIndex].Cells["explanation1"].FormattedValue.ToString(); } cateID = HelperCate.GetCateID(categoryName, explanation); }
void SubDisplayOrders(List <OrderModel> list) { foreach (var item in list) { string ctName = HelperCate.GetCate(Convert.ToInt32(HelperProduct.GetProduct(Convert.ToInt32(item.Products.productID)).cateID)).cateName; dgvOrders.Rows.Add(item.Customers.cFirstName + " " + item.Customers.cLastName, ctName, item.Products.proName, item.piece, item.Products.salePrice, Convert.ToDateTime(item.orderDate).ToShortDateString()); profit += (Convert.ToDouble(item.Products.salePrice) - Convert.ToDouble(item.Products.prePrice)); } lblProfit.Text = profit.ToString(); }
private void BtAddCate_Click(object sender, EventArgs e) { bool result = Helper.I(tbCateName.Text) || Helper.I(tbExp.Text); if (result) { MessageBox.Show("Tüm alanları doldurunuz!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { List <string> list = new List <string>(); foreach (var item in HelperCate.GetCateList()) { list.Add(item.cateName); } if (list.Contains(tbCateName.Text)) { MessageBox.Show("Bu kategori sistemde kayıtlıdır!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Cate ct = new Cate { cateName = tbCateName.Text, explanation = tbExp.Text, addDate = DateTime.Now.Date }; r = Helper.CRUD(null, ct, null, null, null, EntityState.Added, "category"); if (r.isSuccess) { tbCateName.Clear(); tbExp.Clear(); DisplayCategories(); ComboBoxCateSources(); } } } }
private void BtRowDelCate_Click(object sender, EventArgs e) { var ct = HelperCate.GetCate(cateID); if (ct != null) { var result = MessageBox.Show("Bu işlem geri alınamaz. Yine de silinsin mi?", "SİL?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { r = Helper.CRUD(null, ct, null, null, null, EntityState.Deleted, "category"); if (r.isSuccess) { DisplayCategories(); DisplayProducts(); DisplayOrders(); ComboBoxCateSources(); } } } }
private void FormCustomer_Load(object sender, EventArgs e) { lblName.Text = name; lblSname.Text = sname; lblPhone.Text = phone; lblCredit.Text = credit; lblAdress.Text = adress; lblRegion.Text = region; lblCity.Text = city; lblCountry.Text = country; lblPostalCode.Text = postalCode; cBoxCate.Items.Clear(); cBoxSubCate.Items.Clear(); cBoxProduct.Items.Clear(); cBoxCate.ValueMember = "cateID"; cBoxCate.DisplayMember = "cateName"; cBoxCate.DataSource = HelperCate.GetCateList(); cBoxEmployee.ValueMember = "employeeID"; cBoxEmployee.DisplayMember = "eLastName"; cBoxEmployee.DataSource = HelperEmployee.GetEmployeeList(); }
void ComboBoxCateSources() { cbCategoryList.DataSource = HelperCate.GetCateList(); cbCategory.DataSource = HelperCate.GetCateList(); cbCategory1.DataSource = HelperCate.GetCateList(); }
private void CbCategory1_SelectedValueChanged(object sender, EventArgs e) { tbExplanation1.Text = HelperCate.GetCate(Convert.ToInt32(cbCategory1.SelectedValue)).explanation; }