Exemple #1
0
 /// <summary>
 /// Function to insert values to Route Table
 /// </summary>
 /// <param name="routeinfo"></param>
 public void RouteAdd(RouteInfo routeinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RouteAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.RouteName;
         sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
         sprmparam.Value = routeinfo.AreaId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = routeinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Exemple #2
0
        /// <summary>
        /// Function to Update values in Route Table
        /// </summary>
        /// <param name="routeinfo"></param>
        /// <returns></returns>
        public bool RouteEditing(RouteInfo routeinfo)
        {
            bool isEdit = false;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("RouteEditing", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal);
                sprmparam.Value = routeinfo.RouteId;
                sprmparam       = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.RouteName;
                sprmparam       = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
                sprmparam.Value = routeinfo.AreaId;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.Extra2;
                int ina = sccmd.ExecuteNonQuery();
                if (ina > 0)
                {
                    isEdit = true;
                }
                else
                {
                    isEdit = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(isEdit);
        }
Exemple #3
0
        /// <summary>
        /// Function to insert values to Route Table
        /// </summary>
        /// <param name="routeinfo"></param>
        /// <returns></returns>
        public decimal RouteAddParticularFields(RouteInfo routeinfo)
        {
            decimal decAreaId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("RouteAddParticularFields", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.RouteName;
                sprmparam       = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
                sprmparam.Value = routeinfo.AreaId;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = routeinfo.Extra2;
                object objRouteId = sccmd.ExecuteScalar();
                if (objRouteId != null)
                {
                    decAreaId = decimal.Parse(objRouteId.ToString());
                }
                else
                {
                    decAreaId = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decAreaId);
        }
Exemple #4
0
 /// <summary>
 /// creating a default route under the creating area
 /// </summary>
 public void RouteNACreateUnderTheArea()
 {
     try
     {
         RouteSP   spRoute   = new RouteSP();
         RouteInfo infoRoute = new RouteInfo();
         infoRoute.RouteName = "NA";
         infoRoute.AreaId    = decAreaId;
         infoRoute.Narration = txtNarration.Text.Trim();
         infoRoute.Extra1    = string.Empty;
         infoRoute.Extra2    = string.Empty;
         infoRoute.ExtraDate = DateTime.Today;
         spRoute.RouteAdd(infoRoute);
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AR2:" + ex.Message;
     }
 }
 /// <summary>
 /// creating a default route under the creating area
 /// </summary>
 public void RouteNACreateUnderTheArea()
 {
     try
     {
         RouteBll  BllRoute  = new RouteBll();
         RouteInfo infoRoute = new RouteInfo();
         infoRoute.RouteName = "NA";
         infoRoute.AreaId    = decAreaId;
         infoRoute.Narration = txtNarration.Text.Trim();
         infoRoute.Extra1    = string.Empty;
         infoRoute.Extra2    = string.Empty;
         infoRoute.ExtraDate = DateTime.Today;
         BllRoute.RouteAdd(infoRoute);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #6
0
 /// <summary>
 /// creating a default route under the creating area
 /// </summary>
 public void RouteNACreateUnderTheArea()
 {
     try
     {
         RouteSP spRoute = new RouteSP();
         RouteInfo infoRoute = new RouteInfo();
         infoRoute.RouteName = "NA";
         infoRoute.AreaId = decAreaId;
         infoRoute.Narration = txtNarration.Text.Trim();
         infoRoute.Extra1 = string.Empty;
         infoRoute.Extra2 = string.Empty;
         infoRoute.ExtraDate = DateTime.Today;
         spRoute.RouteAdd(infoRoute);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #7
0
        /// <summary>
        /// Function to get particular values from Route table based on the parameter
        /// </summary>
        /// <param name="routeId"></param>
        /// <returns></returns>
        public RouteInfo RouteView(decimal routeId)
        {
            RouteInfo     routeinfo = new RouteInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("RouteView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal);
                sprmparam.Value = routeId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    routeinfo.RouteId   = decimal.Parse(sdrreader[0].ToString());
                    routeinfo.RouteName = sdrreader[1].ToString();
                    routeinfo.AreaId    = decimal.Parse(sdrreader[2].ToString());
                    routeinfo.Narration = sdrreader[3].ToString();
                    routeinfo.ExtraDate = DateTime.Parse(sdrreader[4].ToString());
                    routeinfo.Extra1    = sdrreader[5].ToString();
                    routeinfo.Extra2    = sdrreader[6].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(routeinfo);
        }
 /// <summary>
 /// Function to edit already existing route
 /// </summary>
 public void EditFunction()
 {
     try
     {
         RouteSP   spRoute   = new RouteSP();
         RouteInfo infoRoute = new RouteInfo();
         infoRoute.RouteName = txtRouteName.Text.Trim();
         infoRoute.AreaId    = Convert.ToDecimal(cmbArea.SelectedValue.ToString());
         infoRoute.Narration = txtNarration.Text.Trim();
         infoRoute.Extra1    = String.Empty;
         infoRoute.Extra2    = String.Empty;
         infoRoute.RouteId   = decRouteId;
         if (spRoute.RouteCheckExistence(txtRouteName.Text.Trim(), decRouteId, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false)
         {
             if (spRoute.RouteEditing(infoRoute))
             {
                 Messages.UpdatedMessage();
                 GridFill();
                 Clear();
             }
             else if (infoRoute.RouteId == 1)
             {
                 Messages.InformationMessage("Cannot update");
                 Clear();
                 txtRouteName.Focus();
             }
         }
         else
         {
             Messages.InformationMessage(" Route name already exist");
             txtRouteName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RT5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #9
0
 /// <summary>
 /// Function to Update values in Route Table
 /// </summary>
 /// <param name="routeinfo"></param>
 public void RouteEdit(RouteInfo routeinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RouteEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal);
         sprmparam.Value = routeinfo.RouteId;
         sprmparam       = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.RouteName;
         sprmparam       = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
         sprmparam.Value = routeinfo.AreaId;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = routeinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Exemple #10
0
        /// <summary>
        /// On double clicking on the datagridview, It displays the details of the rack to edit or delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvRoute_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1)
                {
                    if (dgvRoute.Rows[e.RowIndex].Cells["dgvtxtRouteName"].Value.ToString() != "NA")
                    {
                        RouteSP spRoute = new RouteSP();
                        RouteInfo infoRoute = new RouteInfo();
                        infoRoute = spRoute.RouteView(Convert.ToDecimal(dgvRoute.CurrentRow.Cells["dgvtxtRouteId"].Value.ToString()));
                        decRouteId = Convert.ToDecimal(dgvRoute.CurrentRow.Cells["dgvtxtRouteId"].Value.ToString());
                        txtRouteName.Text = infoRoute.RouteName;
                        cmbArea.SelectedValue = infoRoute.AreaId.ToString();
                        txtNarration.Text = infoRoute.Narration;
                        btnSave.Text = "Update";
                        btnDelete.Enabled = true;
                        txtRouteName.Focus();

                    }
                    else
                    {
                        Messages.InformationMessage("Default Route cannot update or delete");
                        Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("RT19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #11
0
 /// <summary>
 /// Function to edit already existing route
 /// </summary>
 public void EditFunction()
 {
     try
     {
         RouteSP spRoute = new RouteSP();
         RouteInfo infoRoute = new RouteInfo();
         infoRoute.RouteName = txtRouteName.Text.Trim();
         infoRoute.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString());
         infoRoute.Narration = txtNarration.Text.Trim();
         infoRoute.Extra1 = String.Empty;
         infoRoute.Extra2 = String.Empty;
         infoRoute.RouteId = decRouteId;
         if (spRoute.RouteCheckExistence(txtRouteName.Text.Trim(), decRouteId, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false)
         {
             if (spRoute.RouteEditing(infoRoute))
             {
                 Messages.UpdatedMessage();
                 GridFill();
                 Clear();
             }
             else if (infoRoute.RouteId == 1)
             {
                 Messages.InformationMessage("Cannot update");
                 Clear();
                 txtRouteName.Focus();
             }
         }
         else
         {
             Messages.InformationMessage(" Route name already exist");
             txtRouteName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RT5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #12
0
 /// <summary>
 /// Function to save the new route
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         RouteSP spRoute = new RouteSP();
         RouteInfo infoRoute = new RouteInfo();
         infoRoute.RouteName = txtRouteName.Text.Trim();
         infoRoute.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString());
         infoRoute.Narration = txtNarration.Text.Trim();
         infoRoute.Extra1 = String.Empty;
         infoRoute.Extra2 = String.Empty;
         if (spRoute.RouteCheckExistence(txtRouteName.Text.Trim(), 0, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false)
         {
             decRoute = spRoute.RouteAddParticularFields(infoRoute);
             {
                 Messages.SavedMessage();
                 Clear();
                 GridFill();
                 if (frmCustomerobj != null)
                 {
                     this.Close();
                 }
             }
         }
         else
         {
             Messages.InformationMessage(" Route name already exist");
             txtRouteName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RT4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #13
0
 /// <summary>
 /// Function to Update values in Route Table
 /// </summary>
 /// <param name="routeinfo"></param>
 /// <returns></returns>
 public bool RouteEditing(RouteInfo routeinfo)
 {
     bool isEdit = false;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RouteEditing", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal);
         sprmparam.Value = routeinfo.RouteId;
         sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.RouteName;
         sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
         sprmparam.Value = routeinfo.AreaId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra2;
         int ina = sccmd.ExecuteNonQuery();
         if (ina > 0)
         {
             isEdit = true;
         }
         else
         {
             isEdit = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return isEdit;
 }
Exemple #14
0
 /// <summary>
 /// Function to insert values to Route Table
 /// </summary>
 /// <param name="routeinfo"></param>
 /// <returns></returns>
 public decimal RouteAddParticularFields(RouteInfo routeinfo)
 {
     decimal decAreaId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RouteAddParticularFields", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.RouteName;
         sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
         sprmparam.Value = routeinfo.AreaId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = routeinfo.Extra2;
         object objRouteId = sccmd.ExecuteScalar();
         if (objRouteId != null)
         {
             decAreaId = decimal.Parse(objRouteId.ToString());
         }
         else
         {
             decAreaId = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decAreaId;
 }
Exemple #15
0
 /// <summary>
 /// Function to get particular values from Route table based on the parameter
 /// </summary>
 /// <param name="routeId"></param>
 /// <returns></returns>
 public RouteInfo RouteView(decimal routeId)
 {
     RouteInfo routeinfo = new RouteInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RouteView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal);
         sprmparam.Value = routeId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             routeinfo.RouteId = decimal.Parse(sdrreader[0].ToString());
             routeinfo.RouteName = sdrreader[1].ToString();
             routeinfo.AreaId = decimal.Parse(sdrreader[2].ToString());
             routeinfo.Narration = sdrreader[3].ToString();
             routeinfo.ExtraDate = DateTime.Parse(sdrreader[4].ToString());
             routeinfo.Extra1 = sdrreader[5].ToString();
             routeinfo.Extra2 = sdrreader[6].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return routeinfo;
 }