private void btnEditProduct_Click(object sender, EventArgs e) { var selectedRows = gvProduct.SelectedRows.ToArray(); if (selectedRows.Length == 0) { MessageBox.Show("خطا! ابتدا یک مورد را برای ویرایش انتخاب کنید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { btnEditProduct.Enabled = true; for (int i = 0; i < selectedRows.Length; i++) { int id = Convert.ToInt32(gvProduct.SelectedRows[i].Cells[0].Value); DialogResult dialogResult = MessageBox.Show(string.Format("آیا میخواهید کد {0} ویرایش شود؟", id), "اخطار", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dialogResult == DialogResult.OK) { Ref_ProductViewModel.Edit(id, txtProductName.Text, txtProductDescription.Text, Convert.ToDecimal(txtProductUnitPrice.Text), Convert.ToInt32(listProductCategory.SelectedValue)); MessageBox.Show(string.Format("کد {0} تغییر یافت", id), "موفق", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //this.productTableAdapter.Fill(onlineShopDataSet.Product); gvProduct.DataSource = Ref_ProductViewModel.FillGrid(); } }
private void btnDeleteProduct_Click(object sender, EventArgs e) { var selectedRows = gvProduct.SelectedRows.ToArray(); if (selectedRows.Length == 0) { MessageBox.Show("خطا! ابتدا یک مورد را برای حذف انتخاب کنید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { btnDeleteProduct.Enabled = true; for (int i = 0; i < selectedRows.Length; i++) { int id = Convert.ToInt32(gvProduct.SelectedRows[i].Cells[0].Value); DialogResult dialogResult = MessageBox.Show(string.Format("آیا میخواهید کد {0} حذف شود؟", id), "اخطار", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dialogResult == DialogResult.OK) { Ref_ProductViewModel.Delete(id); MessageBox.Show(string.Format("کالا با کد {0} حذف شد", id), "موفق", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } //this.productTableAdapter.Fill(onlineShopDataSet.Product); gvProduct.DataSource = Ref_ProductViewModel.FillGrid(); }
private void BtnSubmit_Click(object sender, EventArgs e) { if (Ref_Validation.TextValidation(txtEditProduct.Text) == true && Ref_Validation.NumberValidation(txtEditUnitPrice.Text) == true && Ref_Validation.NumberValidation(txtEditQuantity.Text) == true && Ref_Validation.NumberValidation(txtEditCode.Text) == true ) { ReF_Helper = new Helper(); ReF_Shopping = new shopping(); Ref_ProductViewModel.Edit(Convert.ToInt32(lblEditID.Text) , txtEditProduct.Text, Convert.ToInt32(txtEditUnitPrice.Text), Convert.ToInt32(txtEditQuantity.Text), ReF_Helper.Price(txtEditUnitPrice.Text, txtEditQuantity.Text), Convert.ToInt32(txtEditCode.Text), ReF_Helper.ImageToByteArray(pctrBx.Image)); MessageBox.Show("succeeded"); this.Close(); MessageBox.Show("please enter Refresh Button !!!"); } else { MessageBox.Show("please check fields"); } }
private void Product_Crud_Activated(object sender, EventArgs e) { if (OnlineShopping.View.Helper.ViewHelper.CategoryIdLookup != null) { txtCategoryId.Text = OnlineShopping.View.Helper.ViewHelper.CategoryIdLookup; } if (dgvProduct.RowCount != 0) { dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); } }
private void BtnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(dgvProduct[0, dgvProduct.CurrentRow.Index].Value); DialogResult res = MessageBox.Show("Are you sure ?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { Ref_ProductViewModel.Delete(id); MessageBox.Show("deleted"); dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); } }
private void btnRefreshProduct_Click(object sender, EventArgs e) { //DataTable Product = new DataTable(); //Product = Ref_ProductViewModel.FillGrid(); //foreach (DataRow row in Product.Rows) //{ // gvProduct.Rows.Add(row.ItemArray); //} gvProduct.DataSource = Ref_ProductViewModel.FillGrid(); }
private void InitializeComboBoxes() { #region [cmbCustomer] cmbCustomer.DataSource = Ref_CustomerViewModel.FillGrid(); cmbCustomer.DisplayMember = "CustomerCode"; cmbCustomer.ValueMember = "Id"; #endregion #region [cmbProduct] cmbProduct.DataSource = Ref_ProductViewModel.FillGrid(); cmbProduct.DisplayMember = "ProductCode"; cmbProduct.ValueMember = "Id"; #endregion }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvProduct.RowCount == 0) { MessageBox.Show("The Product List is Empty."); txtProductCode.Focus(); } else { if (dgvProduct.SelectedRows.Count == 0) { MessageBox.Show("Please Selcet a Row."); txtProductCode.Focus(); } else { Int32 selectedRowCount = dgvProduct.SelectedRows.Count; if (selectedRowCount > 0) { Ref_Products_Delete.Clear(); for (int i = 0; i < selectedRowCount; i++) { Ref_Product_Delete = new Model.Helper.SPHelper.Product.SpHelper_Product_Delete(); Ref_Product_Delete.ProductId = (int)dgvProduct.SelectedRows[i].Cells[0].Value; Ref_Products_Delete.Add(Ref_Product_Delete); } Ref_ProductViewModel.Delete(Ref_Products_Delete); if (Init_Database_Exception() != 0) { MessageBox.Show("Delete is Done"); dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); Init_Database_Exception(); if (dgvProduct.RowCount == 0) { MessageBox.Show("The Product List is Empty."); } txtProductCode.Focus(); } } } } }
private void BtnSave_Click(object sender, EventArgs e) { if (Ref_Validation.TextValidation(txtProduct.Text) == true && Ref_Validation.NumberValidation(txtUnitPrice.Text) == true && Ref_Validation.NumberValidation(txtQuantity.Text) == true && Ref_Validation.NumberValidation(txtCode.Text) == true && pictureBox1.Image != null) { ReF_Helper = new Helper(); Ref_ProductViewModel.Save(txtProduct.Text, Convert.ToInt32(txtUnitPrice.Text) , Convert.ToInt32(txtQuantity.Text), ReF_Helper.Price(txtUnitPrice.Text, txtQuantity.Text), Convert.ToInt32(txtCode.Text), ReF_Helper.ImageToByteArray(pictureBox1.Image)); ClearAll(); MessageBox.Show("save"); dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); } else { MessageBox.Show("please check fields"); } }
private void btnSaveProduct_Click(object sender, EventArgs e) { if (txtProductName.Text != "" && txtProductDescription.Text != "" && txtProductUnitPrice.Text != "" && listProductCategory.Text != "") { Ref_ProductViewModel.Save(txtProductName.Text, txtProductDescription.Text, Convert.ToDecimal(txtProductUnitPrice.Text), Convert.ToInt32(listProductCategory.SelectedValue)); MessageBox.Show(string.Format(".کالای جدید ذخیره شد"), "موفق", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.productTableAdapter.Fill(onlineShopDataSet.Product); gvProduct.DataSource = Ref_ProductViewModel.FillGrid(); txtProductName.Text = ""; txtProductDescription.Text = ""; txtProductUnitPrice.Text = ""; listProductCategory.Text = ""; } else { MessageBox.Show("خطا! ابتدا تمام مشخصات کالا را مشخص کنید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSearch_Click(object sender, EventArgs e) { #region [- Trim -] txtProductCode.Text = txtProductCode.Text.Trim(); txtProductName.Text = txtProductName.Text.Trim(); txtCategoryId.Text = txtCategoryId.Text.Trim(); txtQuantity.Text = txtQuantity.Text.Trim(); txtUnitPrice.Text = txtUnitPrice.Text.Trim(); txtDiscount.Text = txtDiscount.Text.Trim(); txtDescriptions.Text = txtDescriptions.Text.Trim(); #endregion Ref_Products_Select.Clear(); if (txtProductCode.Text != "") { Ref_Product_Select.ProductCode = Convert.ToInt32(txtProductCode.Text); } else { Ref_Product_Select.ProductCode = 0; } Ref_Product_Select.ProductName = txtProductName.Text; Ref_Product_Select.Descriptions = txtDescriptions.Text; Ref_Products_Select.Add(Ref_Product_Select); dgvProduct.DataSource = Ref_ProductViewModel.Select(Ref_Products_Select); if (Init_Database_Exception() != 0) { if (dgvProduct.RowCount == 0) { MessageBox.Show("The Product List is Empty."); } txtProductCode.Focus(); } txtProductCode.Focus(); }
private void BtnRefresh_Click(object sender, EventArgs e) { dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); }
private void Shopping_Load(object sender, EventArgs e) { dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); }
private void btnSave_Click(object sender, EventArgs e) { #region [- Trim -] txtProductCode.Text = txtProductCode.Text.Trim(); txtProductName.Text = txtProductName.Text.Trim(); txtCategoryId.Text = txtCategoryId.Text.Trim(); txtQuantity.Text = txtQuantity.Text.Trim(); txtUnitPrice.Text = txtUnitPrice.Text.Trim(); txtDiscount.Text = txtDiscount.Text.Trim(); txtDescriptions.Text = txtDescriptions.Text.Trim(); #endregion #region [- Control Mandatory Fields -] if (txtProductCode.Text == "" || txtProductName.Text == "" || txtCategoryId.Text == "") { if (txtProductCode.Text == "") { MessageBox.Show("Product Code Can Not Be Empty"); txtProductCode.Focus(); } else if (txtProductName.Text == "") { MessageBox.Show("Product Name Can Not Be Empty"); txtProductName.Focus(); } else if (txtCategoryId.Text == "") { MessageBox.Show("Category Id Can Not Be Empty"); btnCategory.Focus(); } } else { #region [- Convert Null To Zero For Price Fields -] if (txtQuantity.Text == "") { txtQuantity.Text = Convert.ToString(0); } if (txtUnitPrice.Text == "") { txtUnitPrice.Text = Convert.ToString(0); } if (txtDiscount.Text == "") { txtDiscount.Text = Convert.ToString(0); } #endregion Ref_Products_Edit.Clear(); Ref_Product_Edit.ProductId = System.Convert.ToInt32(txtProductId.Text); Ref_Product_Edit.ProductCode = Convert.ToInt32(txtProductCode.Text); Ref_Product_Edit.ProductName = txtProductName.Text; Ref_Product_Edit.CategoryId = Convert.ToInt32(txtCategoryId.Text); Ref_Product_Edit.Quantity = Convert.ToInt32(txtQuantity.Text); Ref_Product_Edit.UnitPrice = Convert.ToDecimal(txtUnitPrice.Text); Ref_Product_Edit.Discount = Convert.ToDecimal(txtDiscount.Text); Ref_Product_Edit.Picture = Img; Ref_Product_Edit.Descriptions = txtDescriptions.Text; Ref_Products_Edit.Add(Ref_Product_Edit); Ref_ProductViewModel.Edit(Ref_Products_Edit); if (Init_Database_Exception() != 0) { MessageBox.Show("Edit is Done"); OnlineShopping.View.Helper.ViewHelper.CategoryIdLookup = null; this.Close(); } } #endregion }
private void btnSave_Click(object sender, EventArgs e) { #region [- Trim -] txtProductCode.Text = txtProductCode.Text.Trim(); txtProductName.Text = txtProductName.Text.Trim(); txtCategoryId.Text = txtCategoryId.Text.Trim(); txtQuantity.Text = txtQuantity.Text.Trim(); txtUnitPrice.Text = txtUnitPrice.Text.Trim(); txtDiscount.Text = txtDiscount.Text.Trim(); txtDescriptions.Text = txtDescriptions.Text.Trim(); #endregion #region [- Control Mandatory Fields -] if (txtProductCode.Text == "" || txtProductName.Text == "" || txtCategoryId.Text == "") { if (txtProductCode.Text == "") { MessageBox.Show("Product Code Can Not Be Empty"); txtProductCode.Focus(); } else if (txtProductName.Text == "") { MessageBox.Show("Product Name Can Not Be Empty"); txtProductName.Focus(); } else if (txtCategoryId.Text == "") { MessageBox.Show("Category Id Can Not Be Empty"); btnCategory.Focus(); } } else { #region [- Convert Null To Zero For Price Fields -] if (txtQuantity.Text == "") { txtQuantity.Text = Convert.ToString(0); } if (txtUnitPrice.Text == "") { txtUnitPrice.Text = Convert.ToString(0); } if (txtDiscount.Text == "") { txtDiscount.Text = Convert.ToString(0); } #endregion Ref_Products_Insert.Clear(); Ref_Product_Insert.ProductCode = Convert.ToInt32(txtProductCode.Text); Ref_Product_Insert.ProductName = txtProductName.Text; Ref_Product_Insert.CategoryId = Convert.ToInt32(txtCategoryId.Text); Ref_Product_Insert.Quantity = Convert.ToInt32(txtQuantity.Text); Ref_Product_Insert.UnitPrice = Convert.ToInt32(txtUnitPrice.Text); Ref_Product_Insert.Discount = Convert.ToInt32(txtDiscount.Text); Ref_Product_Insert.Picture = Img; Ref_Product_Insert.Descriptions = txtDescriptions.Text; Ref_Products_Insert.Add(Ref_Product_Insert); Ref_ProductViewModel.Save(Ref_Products_Insert); if (Init_Database_Exception() != 0) { MessageBox.Show("Save is Done"); #region [- Clear Product Form -] txtProductCode.Text = ""; txtProductName.Text = ""; txtCategoryId.Text = ""; txtQuantity.Text = ""; txtUnitPrice.Text = ""; txtDiscount.Text = ""; txtDescriptions.Text = ""; picboImage.Image = null; Img = null; txtProductCode.Focus(); #endregion OnlineShopping.View.Helper.ViewHelper.CategoryIdLookup = null; dgvProduct.DataSource = Ref_ProductViewModel.FillGrid(); Init_Database_Exception(); } } #endregion }