/// <summary> /// On doubleclicking on the grid, It displays the details to edit or delete a rack /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvRack_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { if (dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackName"].Value.ToString() != "NA") { RackSP spRack = new RackSP(); RackInfo infoRack = new RackInfo(); decRackId = Convert.ToDecimal(dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackId"].Value.ToString()); infoRack = spRack.RackView(decRackId); txtRackName.Text = infoRack.RackName; cmbGodown.SelectedValue = infoRack.GodownId.ToString(); txtNarration.Text = infoRack.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; strRackName = infoRack.RackName; txtRackName.Focus(); } else { Messages.InformationMessage("Default Rack cannot update or delete"); Clear(); } } } catch (Exception ex) { MessageBox.Show("R19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save new rack /// </summary> public void SaveFunction() { try { RackSP spRack = new RackSP(); RackInfo rackInfo = new RackInfo(); rackInfo.RackName = txtRackName.Text.Trim(); rackInfo.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString()); rackInfo.Narration = txtNarration.Text.Trim(); rackInfo.ExtraDate = DateTime.Now; rackInfo.Extra1 = string.Empty; rackInfo.Extra2 = string.Empty; decimal decGodounId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString()); if (spRack.RackCheckExistence(txtRackName.Text.Trim(), 0, decGodounId) == false) { decIdForOtherForms = spRack.RackAdd(rackInfo); if (decIdForOtherForms > 0) { Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage(" Rack name already exist"); txtRackName.Focus(); } } catch (Exception ex) { MessageBox.Show("R7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit the existing rack /// </summary> public void EditFunction() { try { RackSP spRack = new RackSP(); RackInfo rackInfo = new RackInfo(); rackInfo.RackName = txtRackName.Text.Trim(); rackInfo.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString()); rackInfo.Narration = txtNarration.Text.Trim(); rackInfo.ExtraDate = DateTime.Now; rackInfo.Extra1 = string.Empty; rackInfo.Extra2 = string.Empty; rackInfo.RackId = decRackId; if (txtRackName.Text != strRackName) { if (CheckExistenceOfRackName() == false) { if (spRack.RackEdit(rackInfo)) { Messages.UpdatedMessage(); Clear(); } } else { Messages.InformationMessage("Already exists"); txtRackName.Focus(); } } else if (rackInfo.RackId == 1) { Messages.InformationMessage("Cannot update"); Clear(); txtRackName.Focus(); } else { if (spRack.RackEdit(rackInfo)) { Messages.UpdatedMessage(); Clear(); } } } catch (Exception ex) { MessageBox.Show("R8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Update values in Rack Table /// </summary> /// <param name="rackinfo"></param> /// <returns></returns> public bool RackEdit(RackInfo rackinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RackEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = rackinfo.RackId; sprmparam = sccmd.Parameters.Add("@rackName", SqlDbType.VarChar); sprmparam.Value = rackinfo.RackName; sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = rackinfo.GodownId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = rackinfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = rackinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = rackinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = rackinfo.Extra2; int inEffectedRow = sccmd.ExecuteNonQuery(); if (inEffectedRow > 0) { return(true); } else { return(false); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } finally { sqlcon.Close(); } }
/// <summary> /// Function to Update values in Rack Table /// </summary> /// <param name="rackinfo"></param> /// <returns></returns> public bool RackEdit(RackInfo rackinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RackEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = rackinfo.RackId; sprmparam = sccmd.Parameters.Add("@rackName", SqlDbType.VarChar); sprmparam.Value = rackinfo.RackName; sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = rackinfo.GodownId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = rackinfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = rackinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = rackinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = rackinfo.Extra2; int inEffectedRow = sccmd.ExecuteNonQuery(); if (inEffectedRow > 0) { return true; } else { return false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return false; } finally { sqlcon.Close(); } }
/// <summary> /// Function to Save Rack /// </summary> public void RackAddCurrespondingtoGodown() { try { RackBll BllRack = new RackBll(); RackInfo infoRack = new RackInfo(); infoRack.RackName = "NA"; infoRack.GodownId = decIdForOtherForms; infoRack.Narration = string.Empty; infoRack.Extra1 = string.Empty; infoRack.Extra2 = string.Empty; infoRack.ExtraDate = DateTime.Now; BllRack.RackAdd(infoRack); } catch (Exception ex) { MessageBox.Show("G3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Save Rack /// </summary> public void RackAddCurrespondingtoGodown() { try { RackSP spRack = new RackSP(); RackInfo infoRack = new RackInfo(); infoRack.RackName = "NA"; infoRack.GodownId = decIdForOtherForms; infoRack.Narration = string.Empty; infoRack.Extra1 = string.Empty; infoRack.Extra2 = string.Empty; infoRack.ExtraDate = DateTime.Now; spRack.RackAdd(infoRack); } catch (Exception ex) { formMDI.infoError.ErrorString = "G3:" + ex.Message; } }
/// <summary> /// Function to get particular values from Rack Table based on the parameter /// </summary> /// <param name="rackId"></param> /// <returns></returns> public RackInfo RackView(decimal rackId) { RackInfo rackinfo = new RackInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RackView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = rackId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { rackinfo.RackId = decimal.Parse(sdrreader[0].ToString()); rackinfo.RackName = sdrreader[1].ToString(); rackinfo.GodownId = decimal.Parse(sdrreader[2].ToString()); rackinfo.Narration = sdrreader[3].ToString(); rackinfo.Extra1 = sdrreader[4].ToString(); rackinfo.Extra2 = sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(rackinfo); }
/// <summary> /// Function to Save Rack /// </summary> public void RackAddCurrespondingtoGodown() { try { RackSP spRack = new RackSP(); RackInfo infoRack = new RackInfo(); infoRack.RackName = "NA"; infoRack.GodownId = decIdForOtherForms; infoRack.Narration = string.Empty; infoRack.Extra1 = string.Empty; infoRack.Extra2 = string.Empty; infoRack.ExtraDate = DateTime.Now; spRack.RackAdd(infoRack); } catch (Exception ex) { MessageBox.Show("G3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Work on dgvProductCreation CellEndEdit event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProductCreation_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvtxtbatch") { string strBatch = dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); if (strBatch != "") { BatchSP spBatch = new BatchSP(); DataTable dtbl = new DataTable(); dtbl = spBatch.BatchViewByName(strBatch, decId); if (dtbl.Rows.Count != 0) { //dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatchId"].Value = Convert.ToDecimal(dtbl.Rows[0]["batchId"]); dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = dtbl.Rows[0]["expiryDate"]; dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = dtbl.Rows[0]["manufacturingDate"]; } } else { dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = string.Empty; dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = string.Empty; } } if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvcmbtgodown") { RackSP spRack = new RackSP(); RackInfo infoRack = new RackInfo(); DataTable dtblRack = new DataTable(); decimal decGodownId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbtgodown"].Value); dtblRack = spRack.RackNamesCorrespondingToGodownId(decGodownId); DataRow drow = dtblRack.NewRow(); drow["rackName"] = string.Empty; drow["rackId"] = 0; dtblRack.Rows.InsertAt(drow, 0); DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbrack"]); cell.DataSource = dtblRack; cell.ValueMember = "rackId"; cell.DisplayMember = "rackName"; } } catch (Exception ex) { MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save new rack /// </summary> public void SaveFunction() { try { RackSP spRack = new RackSP(); RackInfo rackInfo = new RackInfo(); rackInfo.RackName = txtRackName.Text.Trim(); rackInfo.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString()); rackInfo.Narration = txtNarration.Text.Trim(); rackInfo.ExtraDate = DateTime.Now; rackInfo.Extra1 = string.Empty; rackInfo.Extra2 = string.Empty; decimal decGodounId=Convert.ToDecimal(cmbGodown.SelectedValue.ToString()); if (spRack.RackCheckExistence(txtRackName.Text.Trim(), 0, decGodounId) == false) { decIdForOtherForms = spRack.RackAdd(rackInfo); if (decIdForOtherForms > 0) { Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage(" Rack name already exist"); txtRackName.Focus(); } } catch (Exception ex) { MessageBox.Show("R7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from Rack Table based on the parameter /// </summary> /// <param name="rackId"></param> /// <returns></returns> public RackInfo RackView(decimal rackId) { RackInfo rackinfo = new RackInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RackView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = rackId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { rackinfo.RackId = decimal.Parse(sdrreader[0].ToString()); rackinfo.RackName = sdrreader[1].ToString(); rackinfo.GodownId = decimal.Parse(sdrreader[2].ToString()); rackinfo.Narration = sdrreader[3].ToString(); rackinfo.Extra1 = sdrreader[4].ToString(); rackinfo.Extra2 = sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return rackinfo; }
/// <summary> /// Function to add the products to grid /// </summary> public void AddToGrid() { try { SettingsSP spSettings = new SettingsSP(); if (txtProductCode.Text.Trim() == null && txtProductCode.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter product code"); txtProductCode.Focus(); } else if (cmbItem.SelectedIndex == -1 && cmbItem.SelectedValue == null) { Messages.InformationMessage("Select a product"); cmbItem.Focus(); } else if (Convert.ToDecimal(txtQuantity.Text.Trim()) <= 0 || txtQuantity.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter quantity"); txtQuantity.Focus(); } else if (cmbUnit.SelectedValue == null) { Messages.InformationMessage("Select a unit"); cmbUnit.Focus(); } else if (spSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && decimal.Parse(txtRate.Text.Trim()) <= 0 || txtRate.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter rate"); txtRate.Focus(); } else { int inCurrentRowIndex = new int(); bool isExecutef = false; if (rowIdToEdit == 0) { dgvPointOfSales.Rows.Add(); inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1; isExecutef = true; } else { for (int i = 0; i < dgvPointOfSales.Rows.Count; ++i) { if (dgvPointOfSales.Rows[i].Cells["rowId"].Value.ToString() == rowIdToEdit.ToString()) { isExecutef = true; inCurrentRowIndex = i; break; } } } if (!isExecutef) { dgvPointOfSales.Rows.Add(); inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1; } ProductInfo infoProduct = new ProductInfo(); BatchInfo infoBatch = new BatchInfo(); RackInfo infoRack = new RackInfo(); UnitConvertionInfo InfoUnitConvertion = new UnitConvertionInfo(); infoProduct = new ProductSP().ProductView(decProductId); decimal dcProductBatch = new BatchSP().BatchIdViewByProductId(decProductId); InfoUnitConvertion = new UnitConvertionSP().UnitViewAllByProductId(decProductId); infoBatch = new BatchSP().BatchView(dcProductBatch); decimal dcGodownId = infoProduct.GodownId; GodownInfo infoGodown = new GodownInfo(); infoGodown = new GodownSP().GodownView(dcGodownId); decimal dcRackId = infoProduct.RackId; infoRack = new RackSP().RackView(dcRackId); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = txtProductCode.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = cmbItem.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtQuantity"].Value = txtQuantity.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnit"].Value = cmbUnit.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = txtRate.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGrossValue"].Value = txtGrossValue.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxPercentage"].Value = cmbTax.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxAmount"].Value = txtTaxAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtNetAmount"].Value = txtNetAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtDiscount"].Value = txtDiscountAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTotalAmount"].Value = txtAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxttaxid"].Value = Convert.ToDecimal(cmbTax.SelectedValue); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchId"].Value = dcProductBatch; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackId"].Value = infoProduct.RackId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownId"].Value = infoProduct.GodownId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnitId"].Value = Convert.ToDecimal(cmbUnit.SelectedValue); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtunitconversionId"].Value = InfoUnitConvertion.UnitconvertionId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = txtBarcode.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchno"].Value = infoBatch.BatchNo; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownName"].Value = infoGodown.GodownName; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackName"].Value = infoRack.RackName; TotalAmountCalculation(); ClearGroupbox(); dgvPointOfSales.CurrentCell = dgvPointOfSales[0, dgvPointOfSales.Rows.Count - 1]; txtBarcode.Focus(); } } catch (Exception ex) { MessageBox.Show("POS:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }