private void txtUnitPrice_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtUnitPrice.Text != "") { if (Convert.ToDecimal(txtUnitPrice.Text) == 0) { MessageBox.Show(this, "Please enter a Valid UnitPrice", "Wrong Attempt", MessageBoxButtons.OK); } else { objDeliverNoteMaterials.AcceptQty = Convert.ToDecimal(txtQuantity.Text); objDeliverNoteMaterials.ReworkUnitPrice = Convert.ToDecimal(txtUnitPrice.Text); objDeliverNoteMaterials_DL.Update(objDeliverNoteMaterials); this.Close(); } } } }
private void btnGRN_Click(object sender, EventArgs e) { DialogResult TheResult = MessageBox.Show(this, "Have you Finished Entering Details", "Confirmation", MessageBoxButtons.YesNo); if (TheResult == System.Windows.Forms.DialogResult.Yes) { int count = 0; bool CanRaiseGRN = false; foreach (DataGridViewRow dgr in dgvItemList.Rows) { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { count = count + 1; } if (Convert.ToDecimal(dgr.Cells["Quantity"].Value) > 0) { if (Convert.ToDecimal(dgr.Cells["UnitPrice"].Value) > 0) { CanRaiseGRN = true; } else { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { MessageBox.Show(this, "There are some Unit Price With Zeros which is Not allowed", "Error", MessageBoxButtons.OK); } } } else { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { if (Convert.ToDecimal(dgr.Cells["Quantity"].Value) + Convert.ToDecimal(dgr.Cells["RejectQty"].Value) == Convert.ToDecimal(dgr.Cells["TGRNQuantity"].Value)) { DeliverNoteMaterials obj = new DeliverNoteMaterials(); obj = objDeliverNoteMaterials_DL.Get(Convert.ToInt64(dgr.Cells["ID"].Value)); objDeliverNoteMaterials_DL.Update(obj); Clear(); } else { break; } } } } if ((count > 0) && (CanRaiseGRN == true)) { GRN objGRN = new GRN(); objGRN.GRNEnterdBy = CurrentUser.EmployeeID; objGRN.GRNStore = objStore; objGRN.GRNType = GRN.Type.Material; objGRN.GRNStatus = GRN.Status.Initial; objGRN.GRNCategory = 0; int newGRNNO = objGRNDL.Add_Direct_TGRN(objGRN, txtDeliverNote.Text, txtPONo.Text); objGRN.GRNNo = newGRNNO; foreach (DataGridViewRow dgr in dgvItemList.Rows) { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { if (Convert.ToDecimal(dgr.Cells["Quantity"].Value) > 0) { if (Convert.ToDecimal(dgr.Cells["UnitPrice"].Value) > 0) { objGRNMaterials.GRN = objGRN; objGRNMaterials.Material = objMaterialDL.Get(Convert.ToString(dgr.Cells["MaterialCode"].Value)); objGRNMaterials.GrossQty = Convert.ToDecimal(dgr.Cells["Quantity"].Value); objGRNMaterials.NetQty = Convert.ToDecimal(dgr.Cells["Quantity"].Value); objGRNMaterials.UnitPrice = Convert.ToDecimal(dgr.Cells["UnitPrice"].Value); objGRNMaterials.Remarks = "No"; objGRNMaterialsDL.Add_FromDeliverNote(objGRNMaterials, txtDeliverNote.Text); } } } } MessageBox.Show(this, "Sucessfully GRN : GRNNO " + newGRNNO.ToString(), "Successful", MessageBoxButtons.OK); Clear(); } } }