Пример #1
0
 /// <summary>
 /// Function to Update values in Area Table
 /// </summary>
 /// <param name="areainfo"></param>
 public void AreaEdit(AreaInfo areainfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AreaEdit", 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();
     }
 }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
        /// <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);
        }
Пример #6
0
 /// <summary>
 /// Checking the invalid entries fro save or update
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         if (txtAreaName.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter area name");
             txtAreaName.Focus();
         }
         else
         {
             AreaInfo infoArea = new AreaInfo();
             AreaSP   spArea   = new AreaSP();
             infoArea.AreaName  = txtAreaName.Text.Trim();
             infoArea.Narration = txtNarration.Text.Trim();
             infoArea.Extra1    = string.Empty;
             infoArea.Extra2    = string.Empty;
             infoArea.AreaId    = decAreaId;
             if (btnSave.Text == "Save")
             {
                 if (Messages.SaveConfirmation())
                 {
                     if (spArea.AreaNameCheckExistence(txtAreaName.Text.Trim(), 0) == false)
                     {
                         decAreaId = spArea.AreaAddWithIdentity(infoArea);
                         //RouteNACreateUnderTheArea();
                         AreaGridfill();
                         Messages.SavedMessage();
                         Clear();
                         decIdForOtherForms = decAreaId;
                         if (frmRouteObj != null)
                         {
                             this.Close();
                         }
                         if (frmCustomerobj != null)
                         {
                             this.Close();
                         }
                         if (frmSupplierobj != null)
                         {
                             this.Close();
                         }
                     }
                     else
                     {
                         Messages.InformationMessage("Area name already exist");
                         txtAreaName.Focus();
                     }
                 }
             }
             else
             {
                 if (Messages.UpdateConfirmation())
                 {
                     if (spArea.AreaNameCheckExistence(txtAreaName.Text.Trim(), decAreaId) == false)
                     {
                         infoArea.AreaId = decAreaId;
                         if (spArea.AreaUpdate(infoArea))
                         {
                             AreaGridfill();
                             Messages.UpdatedMessage();
                             Clear();
                         }
                         //else if (infoArea.AreaId == 1)
                         //{
                         //    Messages.WarningMessage("Cannot Update or Delete");
                         //    Clear();
                         //    txtAreaName.Focus();
                         //}
                     }
                     else
                     {
                         Messages.InformationMessage("Area name already exist");
                         txtAreaName.Focus();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }