/// <summary> /// Function to insert values to Area Table /// </summary> /// <param name="areainfo"></param> public void AreaAdd(AreaInfo areainfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AreaAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = areainfo.AreaId; sprmparam = sccmd.Parameters.Add("@areaName", SqlDbType.VarChar); sprmparam.Value = areainfo.AreaName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = areainfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = areainfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = areainfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = areainfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
public decimal AreaAddWithIdentity(AreaInfo areainfo) { decimal decAreaId = 0; try { decAreaId = SpArea.AreaAddWithIdentity(areainfo); } catch (Exception ex) { MessageBox.Show("AR3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return decAreaId; }
public AreaInfo AreaFill(decimal decAreaId) { AreaInfo infoArea = new AreaInfo(); try { infoArea = SpArea.AreaFill(decAreaId); } catch (Exception ex) { MessageBox.Show("AR6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return infoArea; }
/// <summary> /// Function to Function to insert values to Area Table and return the Curresponding row's Id /// </summary> /// <param name="areainfo"></param> /// <returns></returns> public decimal AreaAddWithIdentity(AreaInfo areainfo) { decimal decAreaId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AreaAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@areaName", SqlDbType.VarChar); sprmparam.Value = areainfo.AreaName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = areainfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = areainfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = areainfo.Extra2; object objAreaId = sccmd.ExecuteScalar(); if (objAreaId != null) { decAreaId = decimal.Parse(objAreaId.ToString()); } else { decAreaId = 0; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decAreaId; }
public bool AreaUpdate(AreaInfo areainfo) { bool isEdit = false; try { isEdit = SpArea.AreaUpdate(areainfo); } catch (Exception ex) { MessageBox.Show("AR4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isEdit; }
/// <summary> /// Function to get particular values from Area table based on the parameter /// </summary> /// <param name="areaId"></param> /// <returns></returns> public AreaInfo AreaView(decimal areaId) { AreaInfo areainfo = new AreaInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AreaView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = areaId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { areainfo.AreaId = decimal.Parse(sdrreader[0].ToString()); areainfo.AreaName = sdrreader[1].ToString(); areainfo.Narration = sdrreader[2].ToString(); areainfo.ExtraDate = DateTime.Parse(sdrreader[3].ToString()); areainfo.Extra1 = sdrreader[4].ToString(); areainfo.Extra2 = sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return areainfo; }
/// <summary> /// Function to Update the area /// </summary> /// <param name="areainfo"></param> /// <returns></returns> public bool AreaUpdate(AreaInfo areainfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AreaEditParticularField", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = areainfo.AreaId; sprmparam = sccmd.Parameters.Add("@areaName", SqlDbType.VarChar); sprmparam.Value = areainfo.AreaName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = areainfo.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> /// Fuinction to get fill area /// </summary> /// <param name="decAreaId"></param> /// <returns></returns> public AreaInfo AreaFill(decimal decAreaId) { AreaInfo infoArea = new AreaInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AreaWithNarrationView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = decAreaId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { infoArea.AreaId = Convert.ToDecimal(sdrreader[0].ToString()); infoArea.AreaName = sdrreader[1].ToString(); infoArea.Narration = sdrreader[2].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return infoArea; }