public static void UpdateInfo() { if (supplier != null) { supplier = SupplierDataAccess.GetSupplierById(supplier.Id.ToString()); } }
private void frmPurchaseOrderAdd_Load(object sender, EventArgs e) { keyValues = SupplierDataAccess.GetSuppliersForOrder(); if (keyValues != null && cmbSupplier.Items.Count < 1) { foreach (var item in keyValues) { cmbSupplier.Items.Add(item.Value); supplierIds.Add(item.Key); } } if (chkPaid.Checked) { datePaid.Enabled = true; } else { datePaid.Enabled = false; datePaid.Format = DateTimePickerFormat.Custom; datePaid.CustomFormat = " "; } if (orderId > 0) { btnAdd.Text = "Update"; } else { dateOrder.Value = DateTime.Now.Date; } }
public ActionResult CreateEdit(SupplierViewModel model) { try { if (ModelState.IsValid) { if (SupplierDataAccess.Update(model)) { return(Json(new { success = true, message = "berhasil" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, mesage = SupplierDataAccess.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { succes = false, message = "Isi data dulu dengan benar!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private void buttonRegister_Click(object sender, EventArgs e) { if (_isUsernameValid && _isRealNameValid && _isPasswordValid && _isPhoneNumberValid && _isEmailAddressValid) { try { if (SupplierDataAccess.IsUsernameExisted(_username)) { MessageBox.Show("用户名已存在"); return; } SupplierDataAccess.InsertSupplier(_username, _realName, _password, _phoneNumber, _emailAddress); MessageBox.Show("注册成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } Close(); } else { MessageBox.Show("请检查字符串是否匹配"); } }
public ActionResult CreateEdit(SupplierViewModel model) { try { if (ModelState.IsValid) { if (SupplierDataAccess.Update(model)) { return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = SupplierDataAccess.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Please fulfill required fields!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private int AddUpdateSupplier() { if (supplier != null && supplier.Id > 0) { supplier.Id = supplier.Id; supplier.Name = txtName.Text; supplier.Mobile = txtMobile.Text; supplier.Email = txtEmail.Text; supplier.IsActive = chkActive.Checked; supplier.UpdatedBy = userId; return(SupplierDataAccess.UpdateSupplier(supplier)); } else { var supplierDto = new SupplierDTO() { Name = txtName.Text, Email = txtEmail.Text, Mobile = txtMobile.Text, IsActive = chkActive.Checked, CreatedBy = userId }; return(SupplierDataAccess.AddSupplier(supplierDto)); } }
private void iconButtonOK_Click(object sender, EventArgs e) { if (checkPassword()) { SupplierDataAccess.ResetPassword(SupplierInfo.supplier.Id, textBoxNewPassword.Text); MessageBox.Show("重置密码成功"); } }
public ActionResult Edit(int id) { SupplierViewModel model = SupplierDataAccess.GetById(id); ViewBag.ProvinceList = new SelectList(ProvinceDataAccess.GetAll(), "Code", "Name"); ViewBag.CityList = new SelectList(CityDataAccess.GetByProvince(model.Province_Code), "Code", "Name"); return(View(model)); }
// List update from database public override void PopulateFromDatabase() { List <Supplier> supplierList = new SupplierDataAccess().GetAll(); foreach (Supplier stf in supplierList) { list.Add(stf); } }
public void frmSuppliers_Load(object sender, System.EventArgs e) { DataTable dt = SupplierDataAccess.GetSuppliers(); if (dt != null) { this.supplierDataGridView.DataSource = dt; FormatGrid(ref this.supplierDataGridView); } }
public ActionResult DeleteConfirm(int id) { if (SupplierDataAccess.Delete(id)) { return(Json(new { success = true, message = "Sukses" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = SupplierDataAccess.Message }, JsonRequestBehavior.AllowGet)); } }
private void ViewEditData() { supplier = SupplierDataAccess.GetSupplierById(supplierId); if (supplier != null) { txtName.Text = supplier.Name; txtEmail.Text = supplier.Email; txtMobile.Text = supplier.Mobile; chkActive.Checked = supplier.IsActive; } }
public ActionResult GetSupplierByCode(string code) { SupplierViewModel model = SupplierDataAccess.GetByCode(code); if (model != null) { return(Json(new { success = true, data = model }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
private void iconButtonOK_Click(object sender, EventArgs e) { if (CheckInfo()) { try { SupplierDataAccess.UpdateSupplier(SupplierInfo.supplier.Id, textBoxRealName.Text, textBoxPhoneNumber.Text, textBoxEmailAddress.Text); SupplierInfo.UpdateInfo(); MessageBox.Show("修改成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public frmPurchaseOrderAdd(Form frmPurchaseOrder, int userId, int orderId) { this.frmPurchaseOrder = frmPurchaseOrder; this.userId = userId; this.orderId = orderId; InitializeComponent(); keyValues = SupplierDataAccess.GetSuppliersForOrder(); if (keyValues != null && cmbSupplier.Items.Count < 1) { foreach (var item in keyValues) { cmbSupplier.Items.Add(item.Value); supplierIds.Add(item.Key); } } ViewOrderInfo(); }
private void buttonLogin_Click(object sender, EventArgs e) { if (textBoxUsername.Text.Equals("") || textBoxPassword.Text.Equals("")) { MessageBox.Show("用户名或密码为空"); return; } try { SupplierInfo.supplier = SupplierDataAccess.LoginSupplier(textBoxUsername.Text, textBoxPassword.Text); MainForm mainForm = MainForm.CreateForm(); Hide(); mainForm.ShowDialog(); Show(); } catch { MessageBox.Show("登录失败"); } }
private void ShowAllSupplierData() { try { dataGridViewSuppliers.Rows.Clear(); var suppliers = SupplierDataAccess.GetAllSuppliers(); foreach (var supplier in suppliers) { int rowId = dataGridViewSuppliers.Rows.Add(); DataGridViewRow row = dataGridViewSuppliers.Rows[rowId]; row.Cells["Id"].Value = supplier.Id; row.Cells["Username"].Value = supplier.Username; row.Cells["RealName"].Value = supplier.Real_Name; row.Cells["PasswordHash"].Value = supplier.Password_Hash; row.Cells["PhoneNumber"].Value = supplier.Phone_Number; row.Cells["EmailAddress"].Value = supplier.Email_Address; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonFuzzySearch_Click(object sender, EventArgs e) { if (textBoxSearch.Text.Equals("")) { MessageBox.Show("检索关键词为空"); return; } try { switch (comboBoxOption.SelectedIndex) { case 0: ShowSupplierData(SupplierDataAccess.SelectSupplierById(textBoxSearch.Text)); break; case 1: ShowSupplierData(SupplierDataAccess.SelectSupplierByVagueUsername(textBoxSearch.Text)); break; case 2: ShowSupplierData(SupplierDataAccess.SelectSupplierByVagueRealName(textBoxSearch.Text)); break; case 3: ShowSupplierData(SupplierDataAccess.SelectSupplierByVaguePhoneNumber(textBoxSearch.Text)); break; case 4: ShowSupplierData(SupplierDataAccess.SelectSupplierByVagueEmailAddress(textBoxSearch.Text)); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Delete(int id) { return(View(SupplierDataAccess.GetById(id))); }
public ActionResult FilterList(string filterString) { return(View(SupplierDataAccess.GetByFilter(filterString))); }
public ActionResult List() { return(View(SupplierDataAccess.GetAll())); }
private void dataGridViewOrders_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "SupplierDetail" && e.RowIndex >= 0) { string Username_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["SupplierId"].Value.ToString(); var supplier = SupplierDataAccess.GetSupplierById(Username_Value); SupplierDetailForm supplierDetailForm = new SupplierDetailForm(); SendSupplierInfoEvent += supplierDetailForm.ShowDetail; SendSupplierInfoEvent.Invoke(supplier); supplierDetailForm.ShowDialog(); } else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "BookDetail" && e.RowIndex >= 0) { string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value?.ToString(); bool IsNewBook; try { IsNewBook = SupplierOrderDataAccess.GetIsNewBook(OrderId_Value); } catch (MyException ex) { MessageBox.Show(ex.Message); return; } if (!IsNewBook) { var book = BookDataAccess.GetFullBookBySupplierExistentBookOrderId(OrderId_Value); if (book == null) { MessageBox.Show("图书不存在"); return; } BookDetailForm detailForm = new BookDetailForm(); SendBookInfoEvent += detailForm.ShowDetail; SendBookInfoEvent.Invoke(book); detailForm.ShowDialog(); } else { var new_book = NewBookInfoOfSupplierOrderDataAccess.GetNewBookInfoBySupplierOrderId(OrderId_Value); int status_id = new_book.Supplier_Order.Status.Id; if (status_id == 1) // 未入库 { BookUnstockedDetailForm detailForm = new BookUnstockedDetailForm(); SendNewBookInfoEvent += detailForm.ShowNewBookDetail; SendNewBookInfoEvent.Invoke(new_book); detailForm.ShowDialog(); } else // 已入库 { var book = BookDataAccess.GetFullBookByISBN(new_book.Book_ISBN); if (book == null) { MessageBox.Show("图书不存在"); return; } BookDetailForm detailForm = new BookDetailForm(); SendBookInfoEvent += detailForm.ShowDetail; SendBookInfoEvent.Invoke(book); detailForm.ShowDialog(); } } } else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Warehouse" && e.RowIndex >= 0) { string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString(); int StatusId_Value = SupplierOrderDataAccess.GetStatusIdValue(OrderId_Value); if (StatusId_Value == 1) { bool IsNewBook; try { IsNewBook = SupplierOrderDataAccess.GetIsNewBook(OrderId_Value); } catch (MyException ex) { MessageBox.Show(ex.Message); return; } if (IsNewBook) { bool is_on_sale = MessageBox.Show("是否立即上架该图书?", "上架", MessageBoxButtons.OKCancel) == DialogResult.OK; try { SupplierOrderDataAccess.WarehouseNewBook(OrderId_Value, is_on_sale); } catch (MyException ex) { MessageBox.Show(ex.Message); } } else { try { SupplierOrderDataAccess.WarehouseExistentBook(OrderId_Value); } catch (MyException ex) { MessageBox.Show(ex.Message); } } } ShowAllSupplierOrderData(); } else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Cancel" && e.RowIndex >= 0) { string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString(); try { SupplierOrderDataAccess.CancelOrder(OrderId_Value); } catch (Exception ex) { MessageBox.Show("取消订单失败\n" + ex.Message); } ShowAllSupplierOrderData(); } else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0) { string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString(); try { SupplierOrderDataAccess.DeleteOrder(OrderId_Value); } catch (Exception ex) { MessageBox.Show("删除订单失败\n" + ex.Message); } ShowAllSupplierOrderData(); } }
public SupplierService(SupplierDataAccess supplierDataAccess) { _supplierDataAccess = supplierDataAccess; }