Example #1
0
 /// <summary>
 /// Function to Update values in Role Table
 /// </summary>
 /// <param name="infoRole"></param>
 public void RoleEdit(RoleInfo infoRole)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RoleEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal);
         sprmparam.Value = infoRole.RoleId;
         sprmparam = sccmd.Parameters.Add("@role", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Role;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #2
0
 /// <summary>
 /// Save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleSP spRole = new RoleSP();
         infoRole.Role = txtRole.Text.Trim();
         infoRole.Narration = txtNarration.Text.Trim();
         infoRole.Extra1 = string.Empty;
         infoRole.Extra2 = string.Empty;
         string strRole = txtRole.Text.Trim();
         if (spRole.RoleCheckExistence(decRoleId, strRole) == false)
         {
             decRoleId = spRole.RoleAdd(infoRole);
             Messages.SavedMessage();
             ClearFunction();
         }
         else
         {
             Messages.InformationMessage("Role already exists");
             txtRole.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #3
0
 /// <summary>
 /// Function to insert values to Role Table
 /// </summary>
 /// <param name="infoRole"></param>
 /// <returns></returns>
 public decimal RoleAdd(RoleInfo infoRole)
 {
     decimal decRoleIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RoleAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@role", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Role;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra2;
         decRoleIdentity = Convert.ToDecimal(sccmd.ExecuteScalar());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decRoleIdentity;
 }
Example #4
0
 /// <summary>
 /// Delete Function
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         if (PublicVariables.isMessageDelete)
         {
             if (Messages.DeleteMessage())
             {
                 RoleInfo infoRole = new RoleInfo();
                 RoleSP spRole = new RoleSP();
                 if ((spRole.RoleReferenceDelete(decRoleId) == -1))
                 {
                     Messages.ReferenceExistsMessage();
                 }
                 else
                 {
                     Messages.DeletedMessage();
                     btnSave.Text = "Save";
                     btnDelete.Enabled = false;
                     ClearFunction();
                 }
             }
         }
         else
         {
             RoleInfo infoRole = new RoleInfo();
             RoleSP spRole = new RoleSP();
             if (spRole.RoleReferenceDelete(decRoleId) == -1)
             {
                 Messages.ReferenceExistsMessage();
             }
             else
             {
                 Messages.DeletedMessage();
                 btnSave.Text = "Save";
                 btnDelete.Enabled = false;
                 ClearFunction();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #5
0
 /// <summary>
 /// Function to fill the Controls for updation
 /// </summary>
 public void FillControls()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleSP spRole = new RoleSP();
         infoRole = spRole.RoleView(decRoleId);
         txtRole.Text = infoRole.Role;
         txtNarration.Text = infoRole.Narration;
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #6
0
 /// <summary>
 /// Function to Update the items
 /// </summary>
 public void EditFunction()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleSP spRole = new RoleSP();
         infoRole.RoleId = Convert.ToDecimal(dgvRole.CurrentRow.Cells["dgvtxtRoleId"].Value);
         infoRole.Role = txtRole.Text.Trim();
         infoRole.Narration = txtNarration.Text.Trim();
         infoRole.Extra1 = string.Empty;
         infoRole.Extra2 = string.Empty;
         string strRole = txtRole.Text.Trim();
         if (spRole.RoleCheckExistence(decRoleId, strRole) == false)
         {
             spRole.RoleEdit(infoRole);
             Messages.UpdatedMessage();
             ClearFunction();
         }
         else
         {
             Messages.InformationMessage("Role already exists");
             txtRole.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #7
0
 /// <summary>
 /// Function to get particular values from Role table based on the parameter
 /// </summary>
 /// <param name="roleId"></param>
 /// <returns></returns>
 public RoleInfo RoleView(decimal roleId)
 {
     RoleInfo infoRole = new RoleInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RoleView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal);
         sprmparam.Value = roleId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             infoRole.RoleId = decimal.Parse(sdrreader[0].ToString());
             infoRole.Role = sdrreader[1].ToString();
             infoRole.Narration = sdrreader[2].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return infoRole;
 }