/// <summary> /// Function to get particular values from Godown table based on the parameter with narration /// </summary> /// <param name="decGodownId"></param> /// <returns></returns> public GodownInfo GodownWithNarrationView(decimal decGodownId) { GodownInfo godowninfo = new GodownInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownWithNarrationView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = decGodownId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { godowninfo.GodownId = Convert.ToDecimal(sdrreader[0].ToString()); godowninfo.GodownName = sdrreader[1].ToString(); godowninfo.Narration = sdrreader[2].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(godowninfo); }
public GodownInfo GodownIdByGodownName(string strGodown) { GodownInfo godowninfo = new GodownInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam2.Value = strGodown; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { godowninfo.GodownId = Convert.ToDecimal(((DbDataReader)sdrreader)[0].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(godowninfo); }
public bool GodownEditParticularField(GodownInfo godowninfo) { bool isEdit = false; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("godownEditParticularField", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam4 = new SqlParameter(); sprmparam4 = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam4.Value = godowninfo.GodownId; sprmparam4 = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam4.Value = godowninfo.GodownName; sprmparam4 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam4.Value = godowninfo.Narration; int inAffectedRows = sccmd.ExecuteNonQuery(); isEdit = (inAffectedRows > 0 && true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } return(isEdit); }
public void GodownEdit(GodownInfo godowninfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownEdit", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam6 = new SqlParameter(); sprmparam6 = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam6.Value = godowninfo.GodownId; sprmparam6 = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam6.Value = godowninfo.GodownName; sprmparam6 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam6.Value = godowninfo.Narration; sprmparam6 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam6.Value = godowninfo.Extra1; sprmparam6 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam6.Value = godowninfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { GodownInfo infoGodown = new GodownInfo(); GodownSP spGodown = new GodownSP(); infoGodown.GodownName = txtGodownName.Text.Trim(); infoGodown.Narration = txtNarration.Text.Trim(); infoGodown.Extra1 = string.Empty; infoGodown.Extra2 = string.Empty; if (spGodown.GodownCheckIfExist(txtGodownName.Text.Trim(), 0) == false) { decIdForOtherForms = spGodown.GodownAddWithoutSameName(infoGodown); RackAddCurrespondingtoGodown(); if (decIdForOtherForms > 0) { Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage("Godown name already exist"); txtGodownName.Focus(); } } catch (Exception ex) { MessageBox.Show("G4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Update values in Godown Table /// </summary> /// <param name="godowninfo"></param> public void GodownEdit(GodownInfo godowninfo) { try { SPGodown.GodownEdit(godowninfo); } catch (Exception ex) { MessageBox.Show("GBll2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from Godown table based on the parameter /// </summary> /// <param name="godownId"></param> /// <returns></returns> public GodownInfo GodownView(decimal godownId) { GodownInfo godowninfo = new GodownInfo(); try { godowninfo = SPGodown.GodownView(godownId); } catch (Exception ex) { MessageBox.Show("GBll4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(godowninfo); }
/// <summary> /// Function to get the godownId by godownname /// </summary> /// <param name="strGodown"></param> /// <returns></returns> public GodownInfo GodownIdByGodownName(string strGodown) { GodownInfo godowninfo = new GodownInfo(); try { godowninfo = SPGodown.GodownIdByGodownName(strGodown); } catch (Exception ex) { MessageBox.Show("GBll13:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(godowninfo); }
/// <summary> /// Function to Update values in Godown Table /// </summary> /// <param name="godowninfo"></param> /// <returns></returns> public bool GodownEditParticularField(GodownInfo godowninfo) { bool isEdit = false; try { isEdit = SPGodown.GodownEditParticularField(godowninfo); } catch (Exception ex) { MessageBox.Show("GBll11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(isEdit); }
/// <summary> /// Function to insert values to Godown Table with same name /// </summary> /// <param name="godowninfo"></param> /// <returns></returns> public decimal GodownAddWithoutSameName(GodownInfo godowninfo) { decimal decReturnValue = 0; try { decReturnValue = SPGodown.GodownAddWithoutSameName(godowninfo); } catch (Exception ex) { MessageBox.Show("GBll8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decReturnValue); }
/// <summary> /// Function to fill controls for update /// </summary> public void FillControls() { try { GodownInfo infoGodown = new GodownInfo(); GodownSP spGodown = new GodownSP(); infoGodown = spGodown.GodownWithNarrationView(Convert.ToDecimal(dgvGodown.CurrentRow.Cells[1].Value.ToString())); txtGodownName.Text = infoGodown.GodownName; txtNarration.Text = infoGodown.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; decGodownId = infoGodown.GodownId; strGodownName = infoGodown.GodownName; } catch (Exception ex) { MessageBox.Show("G11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to Godown Table with same name /// </summary> /// <param name="godowninfo"></param> /// <returns></returns> public decimal GodownAddWithoutSameName(GodownInfo godowninfo) { // bool isSave = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownAddWithoutSameName", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam.Value = godowninfo.GodownName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = godowninfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = godowninfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = godowninfo.Extra2; decimal decWork = Convert.ToDecimal(sccmd.ExecuteScalar()); if (decWork > 0) { return(decWork); } else { return(0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(0); } finally { sqlcon.Close(); } }
/// <summary> /// Function to Edit /// </summary> public void EditFunction() { try { GodownInfo infoGodown = new GodownInfo(); GodownSP spGodown = new GodownSP(); infoGodown.GodownName = txtGodownName.Text.Trim(); infoGodown.Narration = txtNarration.Text.Trim(); infoGodown.Extra1 = string.Empty; infoGodown.Extra2 = string.Empty; infoGodown.GodownId = Convert.ToDecimal(dgvGodown.CurrentRow.Cells["dgvtxtGodownId"].Value.ToString()); if (txtGodownName.Text != strGodownName) { if (spGodown.GodownCheckIfExist(txtGodownName.Text.Trim(), decGodownId) == false) { if (spGodown.GodownEditParticularField(infoGodown)) { Messages.UpdatedMessage(); Clear(); } } else { Messages.InformationMessage("Godown name already exist"); txtGodownName.Focus(); } } else { spGodown.GodownEditParticularField(infoGodown); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("G5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to add the products to grid /// </summary> public void AddToGrid() { BatchBll BllBatch = new BatchBll(); GodownBll BllGodown = new GodownBll(); try { SettingsBll BllSettings = new SettingsBll(); 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 (BllSettings.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(); ProductCreationBll BllProductCreation = new ProductCreationBll(); UnitConvertionInfo InfoUnitConvertion = new UnitConvertionInfo(); infoProduct = BllProductCreation.ProductView(decProductId); decimal dcProductBatch = BllBatch.BatchIdViewByProductId(decProductId); InfoUnitConvertion = new UnitConvertionBll().UnitViewAllByProductId(decProductId); infoBatch = BllBatch.BatchView(dcProductBatch); decimal dcGodownId = infoProduct.GodownId; GodownInfo infoGodown = new GodownInfo(); infoGodown = BllGodown.GodownView(dcGodownId); decimal dcRackId = infoProduct.RackId; infoRack = new RackBll().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); } }
/// <summary> /// Function to fill controls for update /// </summary> public void FillControls() { try { GodownInfo infoGodown = new GodownInfo(); GodownBll BllGodown = new GodownBll(); infoGodown = BllGodown.GodownWithNarrationView(Convert.ToDecimal(dgvGodown.CurrentRow.Cells[1].Value.ToString())); txtGodownName.Text = infoGodown.GodownName; txtNarration.Text = infoGodown.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; decGodownId = infoGodown.GodownId; strGodownName = infoGodown.GodownName; } catch (Exception ex) { MessageBox.Show("G11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Edit /// </summary> public void EditFunction() { try { GodownInfo infoGodown = new GodownInfo(); GodownBll BllGodown = new GodownBll(); infoGodown.GodownName = txtGodownName.Text.Trim(); infoGodown.Narration = txtNarration.Text.Trim(); infoGodown.Extra1 = string.Empty; infoGodown.Extra2 = string.Empty; infoGodown.GodownId = Convert.ToDecimal(dgvGodown.CurrentRow.Cells["dgvtxtGodownId"].Value.ToString()); if (txtGodownName.Text != strGodownName) { if (BllGodown.GodownCheckIfExist(txtGodownName.Text.Trim(), decGodownId) == false) { if (BllGodown.GodownEditParticularField(infoGodown)) { Messages.UpdatedMessage(); Clear(); } } else { Messages.InformationMessage("Godown name already exist"); txtGodownName.Focus(); } } else { BllGodown.GodownEditParticularField(infoGodown); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("G5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { GodownInfo infoGodown = new GodownInfo(); GodownBll BllGodown = new GodownBll(); infoGodown.GodownName = txtGodownName.Text.Trim(); infoGodown.Narration = txtNarration.Text.Trim(); infoGodown.Extra1 = string.Empty; infoGodown.Extra2 = string.Empty; if (BllGodown.GodownCheckIfExist(txtGodownName.Text.Trim(), 0) == false) { decIdForOtherForms = BllGodown.GodownAddWithoutSameName(infoGodown); RackAddCurrespondingtoGodown(); if (decIdForOtherForms > 0) { Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage("Godown name already exist"); txtGodownName.Focus(); } } catch (Exception ex) { MessageBox.Show("G4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }