public decimal ProductGroupAdd(ProductGroupInfo productgroupinfo) { decimal decIdForOtherForms = 0; try { decIdForOtherForms = spProductGroup.ProductGroupAdd(productgroupinfo); } catch (Exception ex) { MessageBox.Show("AL18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return decIdForOtherForms; }
/// <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 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(); } }
public void ProductGroupEdit(ProductGroupInfo productgroupinfo) { try { spProductGroup.ProductGroupEdit(productgroupinfo); } catch (Exception ex) { MessageBox.Show("AL21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ProductGroupInfo ProductGroupView(decimal groupId) { ProductGroupInfo productgroupinfo = new ProductGroupInfo(); try { productgroupinfo = spProductGroup.ProductGroupView(groupId); } catch (Exception ex) { MessageBox.Show("AL38:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return productgroupinfo; }