Example #1
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);
        }
Example #2
0
 /// <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();
     }
 }
 /// <summary>
 /// area grid cell double click for update
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvArea_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             string strArea = dgvArea.CurrentRow.Cells["dgvtxtarea"].Value.ToString();
             if (strArea != "NA")
             {
                 AreaInfo infoArea = new AreaInfo();
                 AreaBll  BllArea  = new AreaBll();
                 infoArea          = BllArea.AreaFill(Convert.ToDecimal(dgvArea.CurrentRow.Cells[1].Value.ToString()));
                 txtAreaName.Text  = infoArea.AreaName;
                 txtNarration.Text = infoArea.Narration;
                 btnSave.Text      = "Update";
                 btnDelete.Enabled = true;
                 txtAreaName.Focus();
                 decAreaId = Convert.ToDecimal(dgvArea.CurrentRow.Cells[1].Value.ToString());
             }
             else
             {
                 Messages.WarningMessage("NA Area cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #4
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();
     }
 }
Example #5
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);
        }
Example #6
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);
        }
Example #7
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);
        }
Example #8
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)
     {
         formMDI.infoError.ErrorString = "AR3:" + ex.Message;
     }
 }
Example #9
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;
 }
Example #10
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;
 }
Example #11
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;
 }
Example #12
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;
 }
 /// <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();
             AreaBll  BllArea  = new AreaBll();
             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 (BllArea.AreaNameCheckExistence(txtAreaName.Text.Trim(), 0) == false)
                     {
                         decAreaId = BllArea.AreaAddWithIdentity(infoArea);
                         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 (BllArea.AreaNameCheckExistence(txtAreaName.Text.Trim(), decAreaId) == false)
                     {
                         infoArea.AreaId = decAreaId;
                         if (BllArea.AreaUpdate(infoArea))
                         {
                             AreaGridfill();
                             Messages.UpdatedMessage();
                             Clear();
                         }
                     }
                     else
                     {
                         Messages.InformationMessage("Area name already exist");
                         txtAreaName.Focus();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #14
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);
     }
 }
Example #15
0
 /// <summary>
 /// area grid cell double click for update
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvArea_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             
             string strArea = dgvArea.CurrentRow.Cells["dgvtxtarea"].Value.ToString();
             if (strArea != "NA")
             {
                 AreaInfo infoArea = new AreaInfo();
                 AreaSP spArea = new AreaSP();
                 infoArea = spArea.AreaFill(Convert.ToDecimal(dgvArea.CurrentRow.Cells[1].Value.ToString()));
                 txtAreaName.Text = infoArea.AreaName;
                 txtNarration.Text = infoArea.Narration;
                 btnSave.Text = "Update";
                 btnDelete.Enabled = true;
                 txtAreaName.Focus();
                 decAreaId = Convert.ToDecimal(dgvArea.CurrentRow.Cells[1].Value.ToString());
             }
             else
             {
                 Messages.WarningMessage("NA Area cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }