/// <summary> /// Function to get the godownId by godownname /// </summary> /// <param name="strGodown"></param> /// <returns></returns> public GodownInfo GodownIdByGodownName(string strGodown) { GodownInfo godowninfo = new GodownInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam.Value = strGodown; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { godowninfo.GodownId = Convert.ToDecimal(sdrreader[0].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(godowninfo); }
/// <summary> /// Function to Update values in Godown Table /// </summary> /// <param name="godowninfo"></param> public void GodownEdit(GodownInfo godowninfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = godowninfo.GodownId; 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; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { 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) { formMDI.infoError.ErrorString = "G4:" + ex.Message; } }
/// <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); } }
/// <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 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) { formMDI.infoError.ErrorString = "G11:" + ex.Message; } }
/// <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) { formMDI.infoError.ErrorString = "G5:" + ex.Message; } }
/// <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 Update values in Godown Table /// </summary> /// <param name="godowninfo"></param> /// <returns></returns> public bool GodownEditParticularField(GodownInfo godowninfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("godownEditParticularField", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = godowninfo.GodownId; sprmparam = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam.Value = godowninfo.GodownName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = godowninfo.Narration; int inAffectedRows = sccmd.ExecuteNonQuery(); if (inAffectedRows > 0) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isEdit); }
/// <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(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = godownId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { godowninfo.GodownId = Convert.ToDecimal(sdrreader[0].ToString()); godowninfo.GodownName = sdrreader[1].ToString(); godowninfo.Narration = sdrreader[2].ToString(); godowninfo.ExtraDate = Convert.ToDateTime(sdrreader[3].ToString()); godowninfo.Extra1 = sdrreader[4].ToString(); godowninfo.Extra2 = sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(godowninfo); }
/// <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 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(); SqlDataReader sdrreader =null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = godownId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { godowninfo.GodownId = Convert.ToDecimal(sdrreader[0].ToString()); godowninfo.GodownName= sdrreader[1].ToString(); godowninfo.Narration= sdrreader[2].ToString(); godowninfo.ExtraDate=Convert.ToDateTime(sdrreader[3].ToString()); godowninfo.Extra1= sdrreader[4].ToString(); godowninfo.Extra2= sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return godowninfo; }
/// <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 Update values in Godown Table /// </summary> /// <param name="godowninfo"></param> /// <returns></returns> public bool GodownEditParticularField(GodownInfo godowninfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("godownEditParticularField", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = godowninfo.GodownId; sprmparam = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam.Value = godowninfo.GodownName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = godowninfo.Narration; int inAffectedRows = sccmd.ExecuteNonQuery(); if (inAffectedRows > 0) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return isEdit; }
/// <summary> /// Function to get the godownId by godownname /// </summary> /// <param name="strGodown"></param> /// <returns></returns> public GodownInfo GodownIdByGodownName(string strGodown) { GodownInfo godowninfo = new GodownInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GodownView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar); sprmparam.Value = strGodown; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { godowninfo.GodownId = Convert.ToDecimal(sdrreader[0].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return godowninfo; }
/// <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 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 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); } }