コード例 #1
0
    /// <summary>
    /// Gets the professional details.
    /// </summary>
    /// <returns></returns>
    private BusinessEntities.RaveHRCollection GetVisaDetails(int employeeID)
    {
        Rave.HR.BusinessLayer.Employee.VisaDetails objVisaDetailsBAL;
        BusinessEntities.VisaDetails objVisaDetails;

        // Initialise Collection class object
        BusinessEntities.RaveHRCollection raveHRCollection = new BusinessEntities.RaveHRCollection();

        try
        {
            objVisaDetailsBAL = new Rave.HR.BusinessLayer.Employee.VisaDetails();
            objVisaDetails    = new BusinessEntities.VisaDetails();

            //objVisaDetails.EMPId = 14;
            objVisaDetails.EMPId = employeeID;

            raveHRCollection = objVisaDetailsBAL.GetVisaDetails(objVisaDetails);
        }
        catch (RaveHRException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "GetVisaDetails", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }

        return(raveHRCollection);
    }
コード例 #2
0
    /// <summary>
    /// Handles the Click event of the btnAdd control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (ValidateVisaControls())
        {
            BusinessEntities.VisaDetails objVisaDetails = new BusinessEntities.VisaDetails();

            if (gvVisaDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE)
            {
                VisaDetailsCollection.Clear();
            }
            objVisaDetails.CountryName = txtCountryName.Text;
            objVisaDetails.VisaType    = txtVisaType.Text;
            objVisaDetails.ExpiryDate  = Convert.ToDateTime(ucDatePickerVisaExpiryDate.Text);

            objVisaDetails.Mode = 1;

            VisaDetailsCollection.Add(objVisaDetails);

            this.DoDataBind();

            this.ClearControls();

            btnAddRow.Text         = CommonConstants.BTN_AddRow;
            HfIsDataModified.Value = CommonConstants.YES;
        }
    }
コード例 #3
0
    /// <summary>
    /// Handles the RowDeleting event of the gvVisaDetails control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewDeleteEventArgs"/> instance containing the event data.</param>
    protected void gvVisaDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int deleteRowIndex = 0;
        int rowIndex       = -1;

        BusinessEntities.VisaDetails objVisaDetails = new BusinessEntities.VisaDetails();

        deleteRowIndex = e.RowIndex;

        objVisaDetails      = (BusinessEntities.VisaDetails)VisaDetailsCollection.Item(deleteRowIndex);
        objVisaDetails.Mode = 3;

        if (ViewState[VISADETAILSDELETE] != null)
        {
            BusinessEntities.RaveHRCollection objDeleteVisaDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[VISADETAILSDELETE];
            objDeleteVisaDetailsCollection.Add(objVisaDetails);

            ViewState[VISADETAILSDELETE] = objDeleteVisaDetailsCollection;
        }
        else
        {
            BusinessEntities.RaveHRCollection objDeleteVisaDetailsCollection1 = new BusinessEntities.RaveHRCollection();

            objDeleteVisaDetailsCollection1.Add(objVisaDetails);

            ViewState[VISADETAILSDELETE] = objDeleteVisaDetailsCollection1;
        }

        VisaDetailsCollection.RemoveAt(deleteRowIndex);

        ViewState[DELETEROWINDEX] = deleteRowIndex;

        DoDataBind();

        if (ViewState[ROWINDEX] != null)
        {
            rowIndex = Convert.ToInt32(ViewState[ROWINDEX].ToString());
            //check edit index with deleted index if edit index is greater than or equal to delete index then rowindex decremented.
            if (rowIndex != -1 && deleteRowIndex <= rowIndex)
            {
                rowIndex--;
                //store the rowindex in viewstate.
                ViewState[ROWINDEX] = rowIndex;
            }

            ImageButton btnImg = (ImageButton)gvVisaDetails.Rows[rowIndex].FindControl(IMGBTNDELETE);
            btnImg.Enabled = false;

            //Disabling all the edit buttons.
            for (int i = 0; i < gvVisaDetails.Rows.Count; i++)
            {
                if (rowIndex != i)
                {
                    ImageButton btnImgEdit = (ImageButton)gvVisaDetails.Rows[i].FindControl(IMGBTNEDIT);
                    btnImgEdit.Enabled = false;
                }
            }
        }
    }
コード例 #4
0
    /// <summary>
    /// Handles the Click event of the btnSave control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (ValidateControls())
        {
            Rave.HR.BusinessLayer.Employee.VisaDetails objVisaDetailsBAL;
            //Rave.HR.BusinessLayer.Employee.Employee objEmployeeBAL;

            BusinessEntities.VisaDetails      objVisaDetails;
            BusinessEntities.RaveHRCollection objSaveVisaDetailsCollection = new BusinessEntities.RaveHRCollection();

            try
            {
                objEmployeeBAL = new Rave.HR.BusinessLayer.Employee.Employee();

                if (rbtnValidPassport.SelectedIndex == CommonConstants.ZERO)
                {
                    employee.PassportNo         = txtPassportNo.Text;
                    employee.PassportIssuePlace = txtIssuePlace.Text;
                    employee.PassportIssueDate  = Convert.ToDateTime(txtIssueDate.Text);
                    employee.PassportExpireDate = Convert.ToDateTime(txtExpiryDate.Text);

                    if (rbtnValidVisa.SelectedIndex == CommonConstants.ZERO)
                    {
                        objVisaDetailsBAL = new Rave.HR.BusinessLayer.Employee.VisaDetails();

                        if (gvVisaDetails.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                        {
                            for (int i = 0; i < gvVisaDetails.Rows.Count; i++)
                            {
                                objVisaDetails = new BusinessEntities.VisaDetails();

                                Label VisaId = (Label)gvVisaDetails.Rows[i].FindControl(VISAID);
                                Label Mode   = (Label)gvVisaDetails.Rows[i].FindControl(MODE);

                                objVisaDetails.VisaId      = int.Parse(VisaId.Text);
                                objVisaDetails.EMPId       = int.Parse(EMPId.Value);
                                objVisaDetails.CountryName = gvVisaDetails.Rows[i].Cells[0].Text;
                                objVisaDetails.VisaType    = gvVisaDetails.Rows[i].Cells[1].Text;
                                objVisaDetails.ExpiryDate  = Convert.ToDateTime(gvVisaDetails.Rows[i].Cells[2].Text);
                                objVisaDetails.Mode        = int.Parse(Mode.Text);
                                objSaveVisaDetailsCollection.Add(objVisaDetails);
                            }
                        }
                        BusinessEntities.RaveHRCollection objDeleteVisaDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[VISADETAILSDELETE];

                        if (objDeleteVisaDetailsCollection != null)
                        {
                            BusinessEntities.VisaDetails obj = null;

                            for (int i = 0; i < objDeleteVisaDetailsCollection.Count; i++)
                            {
                                objVisaDetails = new BusinessEntities.VisaDetails();
                                obj            = (BusinessEntities.VisaDetails)objDeleteVisaDetailsCollection.Item(i);

                                objVisaDetails.VisaId      = obj.VisaId;
                                objVisaDetails.EMPId       = obj.EMPId;
                                objVisaDetails.CountryName = obj.CountryName;
                                objVisaDetails.VisaType    = obj.VisaType;
                                objVisaDetails.ExpiryDate  = obj.ExpiryDate;
                                objVisaDetails.Mode        = obj.Mode;

                                objSaveVisaDetailsCollection.Add(objVisaDetails);
                            }
                        }
                    }
                    else
                    {
                        //delete visa details if exists.
                        objVisaDetailsBAL = new Rave.HR.BusinessLayer.Employee.VisaDetails();
                        objVisaDetailsBAL.DeleteVisaDetailsByEmpId(employeeID);
                    }
                }
                else
                {
                    employee.PassportNo         = string.Empty;
                    employee.PassportIssuePlace = string.Empty;
                    employee.PassportIssueDate  = DateTime.MinValue;
                    employee.PassportExpireDate = DateTime.MinValue;

                    //delete visa details if exists.
                    objVisaDetailsBAL = new Rave.HR.BusinessLayer.Employee.VisaDetails();
                    objVisaDetailsBAL.DeleteVisaDetailsByEmpId(employeeID);
                }
                Boolean Flag = false;
                objEmployeeBAL.UpdateEmployee(employee, Flag);

                objVisaDetailsBAL.Manipulation(objSaveVisaDetailsCollection);

                if (ViewState.Count > 0)
                {
                    ViewState.Clear();
                }

                //Refresh the grip after saving
                if (EMPId.Value != string.Empty)
                {
                    int empID = Convert.ToInt32(EMPId.Value);
                    //Refresh the grip after saving
                    this.PopulateGrid(empID);
                }

                lblMessage.Text = "Passport details saved successfully.";
            }
            catch (RaveHRException ex)
            {
                LogErrorMessage(ex);
            }
            catch (Exception ex)
            {
                RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "btnSave_Click", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
                LogErrorMessage(objEx);
            }
        }
    }
コード例 #5
0
    /// <summary>
    /// Handles the Click event of the btnUpdateRow control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnUpdateRow_Click(object sender, EventArgs e)
    {
        if (ValidateVisaControls())
        {
            int rowIndex       = 0;
            int deleteRowIndex = -1;

            if (ViewState[DELETEROWINDEX] != null)
            {
                deleteRowIndex = Convert.ToInt32(ViewState[DELETEROWINDEX].ToString());
            }

            //Update the grid view according the row, which is selected for editing.
            if (ViewState[ROWINDEX] != null)
            {
                rowIndex = Convert.ToInt32(ViewState[ROWINDEX].ToString());
                if (deleteRowIndex != -1 && deleteRowIndex < rowIndex)
                {
                    rowIndex--;
                }

                Label VisaId = (Label)gvVisaDetails.Rows[rowIndex].FindControl(VISAID);
                Label Mode   = (Label)gvVisaDetails.Rows[rowIndex].FindControl(MODE);

                gvVisaDetails.Rows[rowIndex].Cells[0].Text = txtCountryName.Text;
                gvVisaDetails.Rows[rowIndex].Cells[1].Text = txtVisaType.Text;
                gvVisaDetails.Rows[rowIndex].Cells[2].Text = txtVisaExpiryDate.Text;

                if (int.Parse(VisaId.Text) == 0)
                {
                    Mode.Text = "1";
                }
                else
                {
                    Mode.Text = "2";
                }

                ImageButton btnImg = (ImageButton)gvVisaDetails.Rows[rowIndex].FindControl(IMGBTNDELETE);
                btnImg.Enabled            = true;
                ViewState[ROWINDEX]       = null;
                ViewState[DELETEROWINDEX] = null;
            }

            for (int i = 0; i < VisaDetailsCollection.Count; i++)
            {
                BusinessEntities.VisaDetails objVisaDetails = new BusinessEntities.VisaDetails();
                objVisaDetails = (BusinessEntities.VisaDetails)VisaDetailsCollection.Item(i);

                Label VisaId = (Label)gvVisaDetails.Rows[i].FindControl(VISAID);
                Label Mode   = (Label)gvVisaDetails.Rows[rowIndex].FindControl(MODE);

                objVisaDetails.VisaId = int.Parse(VisaId.Text);
                objVisaDetails.EMPId  = int.Parse(EMPId.Value);

                objVisaDetails.CountryName = gvVisaDetails.Rows[i].Cells[0].Text;
                objVisaDetails.VisaType    = gvVisaDetails.Rows[i].Cells[1].Text;
                objVisaDetails.ExpiryDate  = Convert.ToDateTime(gvVisaDetails.Rows[i].Cells[2].Text);
                objVisaDetails.Mode        = int.Parse(Mode.Text);
            }

            //Clear all the fields after inserting row into gridview
            this.ClearControls();

            btnAddRow.Visible    = true;
            btnUpdateRow.Visible = false;
            btnCancelRow.Visible = false;

            //Enabling all the edit buttons.
            for (int i = 0; i < gvVisaDetails.Rows.Count; i++)
            {
                ImageButton btnImgEdit = (ImageButton)gvVisaDetails.Rows[i].FindControl(IMGBTNEDIT);
                btnImgEdit.Enabled = true;
            }
        }
    }