private bool insertMaterial(string category, string itemCode, string itemName) { materialBLL uMaterial = new materialBLL(); materialDAL dalMaterial = new materialDAL(); //Add data uMaterial.material_cat = category; uMaterial.material_code = itemCode; uMaterial.material_name = itemName; uMaterial.material_zero_cost = 0; bool success = dalMaterial.Insert(uMaterial); //If the data is successfully inserted then the value of success will be true else false if (success == true) { //Data Successfully Inserted //MessageBox.Show("Material successfully created"); insertItem(category, itemCode, itemName); } else { //Failed to insert data dalMaterial.Delete(uMaterial); MessageBox.Show("Failed to add new material"); } return(success); }
private bool Validation() { bool result = true; if (string.IsNullOrEmpty(txtQty.Text)) { result = false; errorProvider1.SetError(txtQty, "Order Qty Required"); } materialDAL dalMat = new materialDAL(); if (dalMat.checkIfZeroCost(txtItemCode.Text)) { if (!cbZeroCost.Checked) { errorProvider2.SetError(cbZeroCost, txtItemCode.Text + " is a zero cost item"); DialogResult dialogResult = MessageBox.Show(txtItemCode.Text + " is a zero cost item, are you sure you want to make this a PURCHASE order?\n(You can change it by check/uncheck the ZERO COST section)", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult != DialogResult.Yes) { result = false; } } } else { if (cbZeroCost.Checked) { errorProvider2.SetError(cbZeroCost, txtItemCode.Text + " NOT a zero cost item"); DialogResult dialogResult = MessageBox.Show(txtItemCode.Text + " NOT a zero cost item, are you sure you want to make this a ZERO COST order?\n(You can change it by check/uncheck the ZERO COST section)", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult != DialogResult.Yes) { result = false; } } } return(result); }
private bool updateMaterial(string category, string itemCode, string itemName) { materialBLL uMaterial = new materialBLL(); materialDAL dalMaterial = new materialDAL(); //Update data uMaterial.material_cat = category; uMaterial.material_code = itemCode; uMaterial.material_name = itemName; uMaterial.material_zero_cost = 0; bool success = false; if (tool.IfMaterialExists(itemCode)) { success = dalMaterial.Update(uMaterial); } else { success = dalMaterial.Insert(uMaterial); } if (success == true) { //data updated successfully //MessageBox.Show("Material successfully updated "); updateItem(category, itemCode, itemName); } else { //failed to update user MessageBox.Show("Failed to updated material"); } return(success); }
private bool Validation() { bool result = true; if (string.IsNullOrEmpty(cmbItemCat.Text)) { result = false; errorProvider1.SetError(cmbItemCat, "Item Category Required"); } if (string.IsNullOrEmpty(cmbItemName.Text)) { result = false; errorProvider2.SetError(cmbItemName, "Item Name Required"); } if (string.IsNullOrEmpty(cmbItemCode.Text)) { result = false; errorProvider3.SetError(cmbItemCode, "Item Code Required"); } if (string.IsNullOrEmpty(txtQty.Text)) { result = false; errorProvider4.SetError(txtQty, "Item order qty Required"); } if (string.IsNullOrEmpty(cmbQtyUnit.Text)) { result = false; errorProvider5.SetError(cmbQtyUnit, "Item order unit Required"); } if (string.IsNullOrEmpty(dtpRequiredDate.Text)) { result = false; errorProvider6.SetError(dtpRequiredDate, "Item forecast date Required"); } materialDAL dalMat = new materialDAL(); if (dalMat.checkIfZeroCost(cmbItemCode.Text)) { if (!cbZeroCost.Checked) { errorProvider7.SetError(cbZeroCost, cmbItemCode.Text + " is a zero cost item"); DialogResult dialogResult = MessageBox.Show(cmbItemCode.Text + " is a zero cost item, are you sure you want to make this a PURCHASE order?\n(You can change it by check/uncheck the ZERO COST section)", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult != DialogResult.Yes) { result = false; } } } else { if (cbZeroCost.Checked) { errorProvider7.SetError(cbZeroCost, cmbItemCode.Text + " NOT a zero cost item"); DialogResult dialogResult = MessageBox.Show(cmbItemCode.Text + " NOT a zero cost item, are you sure you want to make this a ZERO COST order?\n(You can change it by check/uncheck the ZERO COST section)", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult != DialogResult.Yes) { result = false; } } } return(result); }