/// <summary> /// Function to Update values in ProductGroup Table /// </summary> /// <param name="productgroupinfo"></param> public void ProductGroupEdit(ProductGroupInfo productgroupinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ProductGroupEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@groupId", SqlDbType.Decimal); sprmparam.Value = productgroupinfo.GroupId; sprmparam = sccmd.Parameters.Add("@groupName", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.GroupName; sprmparam = sccmd.Parameters.Add("@groupUnder", SqlDbType.Decimal); sprmparam.Value = productgroupinfo.GroupUnder; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to save new productgroup /// </summary> private void SaveFunction() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); infoProductGroup.GroupName = txtProductGroupName.Text.Trim(); infoProductGroup.GroupUnder = Convert.ToDecimal(cmbUnder.SelectedValue.ToString()); infoProductGroup.Narration = txtNarration.Text.Trim(); infoProductGroup.Extra1 = string.Empty; infoProductGroup.Extra2 = string.Empty; if (spProductGroup.ProductGroupCheckExistence(txtProductGroupName.Text.Trim(), 0) == false) { decIdForOtherForms = spProductGroup.ProductGroupAdd(infoProductGroup); Messages.SavedMessage(); ProductGroupUnderComboFill(); ProductGroupUnderComboFillForSearch(); GridFill(); Clear(); txtProductGroupName.Focus(); } else { Messages.InformationMessage("Product group already exists"); txtProductGroupName.Focus(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "PG4:" + ex.Message; } }
/// <summary> /// Function To edit existing productgroup /// </summary> private void EditFunction() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupBll BllProductGroup = new ProductGroupBll(); infoProductGroup.GroupId = Convert.ToDecimal(dgvProductGroup.CurrentRow.Cells["dgvtxtgroupId"].Value); infoProductGroup.GroupName = txtProductGroupName.Text.Trim(); infoProductGroup.GroupUnder = Convert.ToDecimal(cmbUnder.SelectedValue.ToString()); infoProductGroup.Narration = txtNarration.Text.Trim(); infoProductGroup.Extra1 = string.Empty; infoProductGroup.Extra2 = string.Empty; if (BllProductGroup.ProductGroupCheckExistence(txtProductGroupName.Text.Trim().ToString(), decId) == false) { BllProductGroup.ProductGroupEdit(infoProductGroup); Messages.UpdatedMessage(); ProductGroupUnderComboFill(); ProductGroupUnderComboFillForSearch(); GridFill(); Clear(); txtProductGroupName.Focus(); } else { Messages.InformationMessage(" Product group already exists"); txtProductGroupName.Focus(); } } catch (Exception ex) { MessageBox.Show("PG5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save new productgroup /// </summary> private void SaveFunction() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupBll BllProductGroup = new ProductGroupBll(); infoProductGroup.GroupName = txtProductGroupName.Text.Trim(); infoProductGroup.GroupUnder = Convert.ToDecimal(cmbUnder.SelectedValue.ToString()); infoProductGroup.Narration = txtNarration.Text.Trim(); infoProductGroup.Extra1 = string.Empty; infoProductGroup.Extra2 = string.Empty; if (BllProductGroup.ProductGroupCheckExistence(txtProductGroupName.Text.Trim(), 0) == false) { decIdForOtherForms = BllProductGroup.ProductGroupAdd(infoProductGroup); Messages.SavedMessage(); ProductGroupUnderComboFill(); ProductGroupUnderComboFillForSearch(); GridFill(); Clear(); txtProductGroupName.Focus(); } else { Messages.InformationMessage("Product group already exists"); txtProductGroupName.Focus(); } } catch (Exception ex) { MessageBox.Show("PG4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete productgroup /// </summary> private void Delete() { try { if (PublicVariables.isMessageDelete) { if (Messages.DeleteMessage() == true) { ProductGroupInfo InfoProductGroup = new ProductGroupInfo(); ProductGroupBll BllProductGroup = new ProductGroupBll(); if ((BllProductGroup.ProductGroupReferenceDelete(decId) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; ProductGroupUnderComboFillForSearch(); Clear(); } } } else { ProductGroupInfo InfoProductGroup = new ProductGroupInfo(); ProductGroupBll BllProductGroup = new ProductGroupBll(); if ((BllProductGroup.ProductGroupReferenceDelete(decId) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; Clear(); } } } catch (Exception ex) { MessageBox.Show("PG6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete productgroup /// </summary> private void Delete() { try { if (PublicVariables.isMessageDelete) { if (Messages.DeleteMessage() == true) { ProductGroupInfo InfoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); if ((spProductGroup.ProductGroupReferenceDelete(decId) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; ProductGroupUnderComboFillForSearch(); Clear(); } } } else { ProductGroupInfo InfoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); if ((spProductGroup.ProductGroupReferenceDelete(decId) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; Clear(); } } } catch (Exception ex) { formMDI.infoError.ErrorString = "PG6:" + ex.Message; } }
/// <summary> /// Function to fill the grid to view all the product groups /// </summary> private void GridFill() { try { List <DataTable> listObj = new List <DataTable>(); ProductGroupBll BllProductGroup = new ProductGroupBll(); ProductGroupInfo info = new ProductGroupInfo(); if (cmbUnderSearch.Text == "") { cmbUnderSearch.Text = "All"; } listObj = BllProductGroup.ProductGroupViewForGridFill(txtProductGroupSearch.Text, cmbUnderSearch.Text); dgvProductGroup.DataSource = listObj[0]; } catch (Exception ex) { MessageBox.Show("PG9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the grid to view all the product groups /// </summary> private void GridFill() { try { DataTable dtbl = new DataTable(); ProductGroupSP spProducttGroup = new ProductGroupSP(); ProductGroupInfo info = new ProductGroupInfo(); if (cmbUnderSearch.Text == "") { cmbUnderSearch.Text = "All"; } dtbl = spProducttGroup.ProductGroupViewForGridFill(txtProductGroupSearch.Text, cmbUnderSearch.Text); dgvProductGroup.DataSource = dtbl; } catch (Exception ex) { MessageBox.Show("PG9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the grid to view all the product groups /// </summary> private void GridFill() { try { DataTable dtbl = new DataTable(); ProductGroupSP spProducttGroup = new ProductGroupSP(); ProductGroupInfo info = new ProductGroupInfo(); if (cmbUnderSearch.Text == "") { cmbUnderSearch.Text = "All"; } dtbl = spProducttGroup.ProductGroupViewForGridFill(txtProductGroupSearch.Text, cmbUnderSearch.Text); dgvProductGroup.DataSource = dtbl; } catch (Exception ex) { formMDI.infoError.ErrorString = "PG8:" + ex.Message; } }
/// <summary> /// Function to insert values to ProductGroup Table /// </summary> /// <param name="productgroupinfo"></param> /// <returns></returns> public decimal ProductGroupAdd(ProductGroupInfo productgroupinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ProductGroupAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@groupName", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.GroupName; sprmparam = sccmd.Parameters.Add("@groupUnder", SqlDbType.Decimal); sprmparam.Value = productgroupinfo.GroupUnder; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Extra2; decimal decIdForOtherForms = Convert.ToDecimal(sccmd.ExecuteScalar()); if (decIdForOtherForms > 0) { return(decIdForOtherForms); } else { return(0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(0); } finally { sqlcon.Close(); } }
/// <summary> /// Function to insert values to ProductGroup Table /// </summary> /// <param name="productgroupinfo"></param> /// <returns></returns> public decimal ProductGroupAdd(ProductGroupInfo productgroupinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ProductGroupAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@groupName", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.GroupName; sprmparam = sccmd.Parameters.Add("@groupUnder", SqlDbType.Decimal); sprmparam.Value = productgroupinfo.GroupUnder; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = productgroupinfo.Extra2; decimal decIdForOtherForms = Convert.ToDecimal(sccmd.ExecuteScalar()); if (decIdForOtherForms > 0) { return decIdForOtherForms; } else { return 0; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return 0; } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from ProductGroup table based on the parameter /// </summary> /// <param name="groupId"></param> /// <returns></returns> public ProductGroupInfo ProductGroupView(decimal groupId) { ProductGroupInfo productgroupinfo = new ProductGroupInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ProductGroupView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@groupId", SqlDbType.Decimal); sprmparam.Value = groupId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { productgroupinfo.GroupId = decimal.Parse(sdrreader[0].ToString()); productgroupinfo.GroupName = sdrreader[1].ToString(); productgroupinfo.GroupUnder = decimal.Parse(sdrreader[2].ToString()); productgroupinfo.Narration = sdrreader[3].ToString(); productgroupinfo.Extra1 = sdrreader[4].ToString(); productgroupinfo.Extra2 = sdrreader[5].ToString(); productgroupinfo.ExtraDate = DateTime.Parse(sdrreader[6].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(productgroupinfo); }
/// <summary> /// Function to fill the fields to edit or delete /// </summary> private void FillControls() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); infoProductGroup = spProductGroup.ProductGroupView(decId); txtProductGroupName.Text = infoProductGroup.GroupName; DataTable dtbl = new DataTable(); dtbl = spProductGroup.ProductGroupViewForComboFillForProductGroup(); cmbUnder.DataSource = dtbl; foreach (DataRow dr in dtbl.Rows) { if (dr["GroupName"].ToString() == txtProductGroupName.Text) { dr.Delete(); } } cmbUnder.ValueMember = "GroupId"; cmbUnder.DisplayMember = "GroupName"; cmbUnder.SelectedValue = infoProductGroup.GroupUnder; if (spProductGroup.ProductGroupCheckExistenceOfUnderGroup(decId) == false) { cmbUnder.Enabled = false; } else { cmbUnder.Enabled = true; } txtNarration.Text = infoProductGroup.Narration; } catch (Exception ex) { formMDI.infoError.ErrorString = "PG9:" + ex.Message; } }
/// <summary> /// Function to fill the fields to edit or delete /// </summary> private void FillControls() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupBll BllProductgroup = new ProductGroupBll(); infoProductGroup = BllProductgroup.ProductGroupView(decId); txtProductGroupName.Text = infoProductGroup.GroupName; List <DataTable> listObj = new List <DataTable>(); listObj = BllProductgroup.ProductGroupViewForComboFillForProductGroup(); cmbUnder.DataSource = listObj[0]; foreach (DataRow dr in listObj[0].Rows) { if (dr["GroupName"].ToString() == txtProductGroupName.Text) { dr.Delete(); } } cmbUnder.ValueMember = "GroupId"; cmbUnder.DisplayMember = "GroupName"; cmbUnder.SelectedValue = infoProductGroup.GroupUnder; if (BllProductgroup.ProductGroupCheckExistenceOfUnderGroup(decId) == false) { cmbUnder.Enabled = false; } else { cmbUnder.Enabled = true; } txtNarration.Text = infoProductGroup.Narration; } catch (Exception ex) { MessageBox.Show("PG10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save new productgroup /// </summary> private void SaveFunction() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); infoProductGroup.GroupName = txtProductGroupName.Text.Trim(); infoProductGroup.GroupUnder = Convert.ToDecimal(cmbUnder.SelectedValue.ToString()); infoProductGroup.Narration = txtNarration.Text.Trim(); infoProductGroup.Extra1 = string.Empty; infoProductGroup.Extra2 = string.Empty; if (spProductGroup.ProductGroupCheckExistence(txtProductGroupName.Text.Trim(), 0) == false) { decIdForOtherForms = spProductGroup.ProductGroupAdd(infoProductGroup); Messages.SavedMessage(); ProductGroupUnderComboFill(); ProductGroupUnderComboFillForSearch(); GridFill(); Clear(); txtProductGroupName.Focus(); } else { Messages.InformationMessage("Product group already exists"); txtProductGroupName.Focus(); } } catch (Exception ex) { MessageBox.Show("PG4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from ProductGroup table based on the parameter /// </summary> /// <param name="groupId"></param> /// <returns></returns> public ProductGroupInfo ProductGroupView(decimal groupId) { ProductGroupInfo productgroupinfo = new ProductGroupInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ProductGroupView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@groupId", SqlDbType.Decimal); sprmparam.Value = groupId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { productgroupinfo.GroupId = decimal.Parse(sdrreader[0].ToString()); productgroupinfo.GroupName = sdrreader[1].ToString(); productgroupinfo.GroupUnder = decimal.Parse(sdrreader[2].ToString()); productgroupinfo.Narration = sdrreader[3].ToString(); productgroupinfo.Extra1 = sdrreader[4].ToString(); productgroupinfo.Extra2 = sdrreader[5].ToString(); productgroupinfo.ExtraDate = DateTime.Parse(sdrreader[6].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return productgroupinfo; }
/// <summary> /// Function To edit existing productgroup /// </summary> private void EditFunction() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); infoProductGroup.GroupId = Convert.ToDecimal(dgvProductGroup.CurrentRow.Cells["dgvtxtgroupId"].Value); infoProductGroup.GroupName = txtProductGroupName.Text.Trim(); infoProductGroup.GroupUnder = Convert.ToDecimal(cmbUnder.SelectedValue.ToString()); infoProductGroup.Narration = txtNarration.Text.Trim(); infoProductGroup.Extra1 = string.Empty; infoProductGroup.Extra2 = string.Empty; if (spProductGroup.ProductGroupCheckExistence(txtProductGroupName.Text.Trim().ToString(), decId) == false) { spProductGroup.ProductGroupEdit(infoProductGroup); Messages.UpdatedMessage(); ProductGroupUnderComboFill(); ProductGroupUnderComboFillForSearch(); GridFill(); Clear(); txtProductGroupName.Focus(); } else { Messages.InformationMessage(" Product group already exists"); txtProductGroupName.Focus(); } } catch (Exception ex) { MessageBox.Show("PG5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete productgroup /// </summary> private void Delete() { try { if (PublicVariables.isMessageDelete) { if (Messages.DeleteMessage() == true) { ProductGroupInfo InfoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); if ((spProductGroup.ProductGroupReferenceDelete(decId) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; ProductGroupUnderComboFillForSearch(); Clear(); } } } else { ProductGroupInfo InfoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); if ((spProductGroup.ProductGroupReferenceDelete(decId) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; Clear(); } } } catch (Exception ex) { MessageBox.Show("PG6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the fields to edit or delete /// </summary> private void FillControls() { try { ProductGroupInfo infoProductGroup = new ProductGroupInfo(); ProductGroupSP spProductGroup = new ProductGroupSP(); infoProductGroup = spProductGroup.ProductGroupView(decId); txtProductGroupName.Text = infoProductGroup.GroupName; DataTable dtbl = new DataTable(); dtbl = spProductGroup.ProductGroupViewForComboFillForProductGroup(); cmbUnder.DataSource = dtbl; foreach (DataRow dr in dtbl.Rows) { if (dr["GroupName"].ToString() == txtProductGroupName.Text) dr.Delete(); } cmbUnder.ValueMember = "GroupId"; cmbUnder.DisplayMember = "GroupName"; cmbUnder.SelectedValue = infoProductGroup.GroupUnder; if (spProductGroup.ProductGroupCheckExistenceOfUnderGroup(decId) == false) { cmbUnder.Enabled = false; } else { cmbUnder.Enabled = true; } txtNarration.Text = infoProductGroup.Narration; } catch (Exception ex) { MessageBox.Show("PG10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }