protected void rcmb_DestinationPosition_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        try
        {
            if (rcmb_DestinationPosition.SelectedIndex > 0)
            {
                _obj_smhr_positions                 = new SMHR_POSITIONS();
                _obj_smhr_positions.OPERATION       = operation.Empty;
                _obj_smhr_positions.POSITIONS_ID    = Convert.ToInt32(rcmb_DestinationPosition.SelectedValue);
                _obj_smhr_positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                DataTable dt = BLL.get_Positions(_obj_smhr_positions);
                if (dt.Rows.Count != 0)
                {
                    lbl_DestinationJob.Text = Convert.ToString(dt.Rows[0]["JOBS_CODE"]);
                    if (Convert.ToString(dt.Rows[0]["JOBS_ID"]) != "")
                    {
                        SMHR_JOBS _obj_Jobs = new SMHR_JOBS();
                        _obj_Jobs.JOBS_ID = Convert.ToInt32(dt.Rows[0]["JOBS_ID"]);
                        DataTable dt1 = BLL.get_Jobs(_obj_Jobs);
                        maxsal = Convert.ToDouble(dt1.Rows[0]["JOBS_MAXSAL"]);
                        minsal = Convert.ToDouble(dt1.Rows[0]["JOBS_MINSAL"]);
                        if (txt_MonthlyGross.Text != "")
                        {
                            //for validating job minsal and maxsal with the gross
                            if (!((Convert.ToDouble(txt_MonthlyGross.Text) >= minsal) && (Convert.ToDouble(txt_MonthlyGross.Text) <= maxsal)))
                            {
                                BLL.ShowMessage(this, "Gross Must be in the range of Selected Job Min and Max Salary:" + minsal + "-" + maxsal);
                                txt_MonthlyGross.Text = "";
                                txt_MonthlyBasic.Text = "";
                                return;
                            }
                        }
                    }
                }
            }
            //lbl_DestinationJob.Text = Convert.ToString(dt.Rows[0]["JOBS_CODE"]);

            //rcmb_DestinationJob.DataSource = dt;
            //rcmb_DestinationJob.DataTextField = "JOBS_CODE";
            //rcmb_DestinationJob.DataValueField = "JOBS_ID";
            //rcmb_DestinationJob.DataBind();
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "EmployeeCopy", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
            return;
        }
    }
 public void LoadGrid()
 {
     try
     {
         SMHR_POSITIONS _obj_smhr_Position = new SMHR_POSITIONS();
         _obj_smhr_Position.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"].ToString());
         DataTable DT = BLL.get_Positions(_obj_smhr_Position);
         Rg_Positions.DataSource = DT;
         clearControls();
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frmPosition", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
    protected void lnk_Edit_Command(object sender, CommandEventArgs e)
    {
        try
        {
            loadDropdown();
            clearControls();
            SMHR_POSITIONS _obj_Smhr_Positions = new SMHR_POSITIONS();
            _obj_Smhr_Positions.POSITIONS_ID    = Convert.ToInt32(Convert.ToString(e.CommandArgument));
            _obj_Smhr_Positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
            DataTable dt = BLL.get_Positions(_obj_Smhr_Positions);
            //rtxt_PositionsCode.Enabled = false;
            rcmb_PositionsJobs.Enabled       = false;
            lbl_PositionsID.Text             = Convert.ToString(dt.Rows[0]["POSITIONS_ID"]);
            rtxt_PositionsCode.Text          = Convert.ToString(dt.Rows[0]["POSITIONS_CODE"]);
            rtxt_PositionsDesc.Text          = Convert.ToString(dt.Rows[0]["POSITIONS_DESC"]);
            rcmb_PositionsJobs.SelectedIndex = rcmb_PositionsJobs.Items.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["POSITIONS_JOBSID"]));
            rcmb_PositionsJobs_SelectedIndexChanged(null, null);
            rcmb_PositionsStatus.SelectedIndex   = rcmb_PositionsStatus.Items.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["POSITIONS_STATUS"]));
            rdtp_PositionsStartDate.SelectedDate = null;
            rdtp_PositionsEndDate.SelectedDate   = null;

            if (dt.Rows[0]["POSITIONS_STARTDATE"] != DBNull.Value)
            {
                rdtp_PositionsStartDate.SelectedDate = Convert.ToDateTime(dt.Rows[0]["POSITIONS_STARTDATE"]);
            }
            if (dt.Rows[0]["POSITIONS_ENDDATE"] != DBNull.Value)
            {
                rdtp_PositionsEndDate.SelectedDate = Convert.ToDateTime(dt.Rows[0]["POSITIONS_ENDDATE"]);
            }
            if (Convert.ToInt32(Session["WRITEFACILITY"]) == 2)
            {
                btn_Edit.Visible = false;
            }

            else
            {
                btn_Edit.Visible = true;
            }

            Rm_PO_page.SelectedIndex = 1;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frmPosition", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
Exemple #4
0
 private void LoadCombos()
 {
     try
     {
         _obj_smhr_positions           = new SMHR_POSITIONS();
         _obj_smhr_positions.OPERATION = operation.Select;
         DataTable dt = BLL.get_Positions(_obj_smhr_positions);
         rcmb_Position.DataSource     = dt;
         rcmb_Position.DataTextField  = "POSITIONS_CODE";
         rcmb_Position.DataValueField = "POSITIONS_ID";
         rcmb_Position.DataBind();
         rcmb_Position.Items.Insert(0, new RadComboBoxItem("Select"));
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_DesgLogReportDaily", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
 private void getPosition()
 {
     try
     {
         rcmb_DestinationPosition.Items.Clear();
         SMHR_POSITIONS _obj_smhr_positions = new SMHR_POSITIONS();
         _obj_smhr_positions.OPERATION = operation.Select;
         _obj_smhr_positions.JOBLOC_BUSINESSUNIT_ID = Convert.ToInt32(rcmb_DestinationBU.SelectedValue);
         _obj_smhr_positions.ORGANISATION_ID        = Convert.ToInt32(Session["ORG_ID"]);
         rcmb_DestinationPosition.DataSource        = BLL.get_BUPositions(_obj_smhr_positions);
         rcmb_DestinationPosition.DataTextField     = "POSITIONS_CODE";
         rcmb_DestinationPosition.DataValueField    = "POSITIONS_ID";
         rcmb_DestinationPosition.DataBind();
         rcmb_DestinationPosition.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("Select"));
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "EmployeeCopy", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
         return;
     }
 }
Exemple #6
0
 private void getJob(string strPosition)
 {
     try
     {
         if (strPosition != "")
         {
             _obj_smhr_positions                 = new SMHR_POSITIONS();
             _obj_smhr_positions.OPERATION       = operation.Empty;
             _obj_smhr_positions.POSITIONS_ID    = Convert.ToInt32(strPosition);
             _obj_smhr_positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
             DataTable dt = BLL.get_Positions(_obj_smhr_positions);
             if (dt.Rows.Count != 0)
             {
                 rtxt_Jobs.Text = Convert.ToString(dt.Rows[0]["JOBS_CODE"]);
             }
         }
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frmemppayelements", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
    protected void btn_Import_Click(object sender, EventArgs e)
    {
        try
        {
            string strcon   = null;
            string errormsg = "";
            string filename = fupld_Position.FileName;
            filedatetime = Convert.ToString(DateTime.Now.TimeOfDay) + "_" + filename;
            filedatetime = filedatetime.Replace("/", "").Replace(":", ".");
            if (fupld_Position.HasFile)
            {
                if (System.IO.Directory.Exists(Server.MapPath("~/IMPORT_EXCEL/")) == false)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("~/IMPORT_EXCEL/"));
                }
                fupld_Position.PostedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/IMPORT_EXCEL/"), filedatetime));
                string   filename1 = Server.MapPath("~/IMPORT_EXCEL/") + ("") + (Convert.ToString(filedatetime));
                FileInfo fileInfo  = new FileInfo(filename1);
                if (fileInfo.Exists)
                {
                    string path = MapPath(filename);
                    string ext  = Path.GetExtension(path);
                    string type = string.Empty;

                    //  set known types based on file extension
                    if (ext != null)
                    {
                        switch (ext.ToLower())
                        {
                        case ".xls": type = "excel";
                            break;

                        case ".xlsx": type = "excel";
                            break;

                        default: type = string.Empty;
                            break;
                        }
                    }
                    if (type == string.Empty)
                    {
                        if (System.IO.Directory.Exists(Server.MapPath("~/IMPORT_EXCEL/")) == true)
                        {
                            string path1 = Server.MapPath("~/IMPORT_EXCEL/") + ("") + (Convert.ToString(filedatetime));
                            System.IO.File.Delete(path1);
                        }
                        BLL.ShowMessage(this, "Please select the Excel File  (Eg: Excel.xlsx). ");
                        return;
                    }
                }
            }
            else
            {
                BLL.ShowMessage(this, "Please Select the File to be uploaded");
                return;
            }
            string strpath = Server.MapPath("~/IMPORT_EXCEL/");
            strpath = strpath + filedatetime;


            // Getting data from excell file to dataset.
            strcon = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source='" + strpath + "';" + "Extended Properties=Excel 12.0;";
            OleDbConnection objConn = null;
            objConn = new OleDbConnection(strcon);
            objConn.Open();

            DataTable dt_check = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            string    sheetname;
            if (dt_check == null)
            {
                objConn.Close();
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            else
            {
                sheetname = Convert.ToString(dt_check.Rows[0]["TABLE_NAME"]);
            }
            OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM  [" + sheetname + "]", strcon);
            da.Fill(ds);
            ds.Tables[0].Columns.Add("Error Message");
            objConn.Close();
            DataTable dt          = new DataTable();
            DataTable dtfail      = new DataTable();
            string    projecttype = null;
            Int32     rowno       = 0;
            string    columnno    = null;
            //Boolean filestatus = true;
            dtfail.Columns.Add("S.NO", typeof(Int32));
            dtfail.Columns.Add("ROWNO", typeof(Int32));
            dtfail.Columns.Add("COLUMNS NAME", typeof(string));
            //For Checking The Position Name Field Is There or not in the excel sheet
            if (!(ds.Tables[0].Columns[0].ToString().Trim() == "Name *"))
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            //For Checking The Position Description Field Is There or not in the excel sheet
            if (!(ds.Tables[0].Columns[1].ToString().Trim() == "Description"))
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            //For Checking The Availability of Job Field
            if (!(ds.Tables[0].Columns[2].ToString() == "Job *"))
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }

            //For Checking The Availability of Status
            if (!(ds.Tables[0].Columns[3].ToString() == "Status *"))
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }

            //For Checking The Availability of Start Date
            if (!(ds.Tables[0].Columns[4].ToString() == "Start Date *(DD/MM/YYYY)"))
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            //For Checking The Availability of End Date
            if (!(ds.Tables[0].Columns[5].ToString() == "End Date (DD/MM/YYYY)"))
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }

            //For Checking The Availability of the Records In The Excel Sheet
            if (ds.Tables[0].Rows.Count == 0)
            {
                BLL.ShowMessage(this, "Imported Successfully But There is No Record Available!");
                Delete_Excel_File();
                return;
            }
            else
            {
                bool           IsCorrect           = true;
                bool           found               = false;
                int            jobid               = 0;
                SMHR_POSITIONS _obj_Smhr_Positions = new SMHR_POSITIONS();
                loadDropdown();
                //For Validating The Excel Sheet
                for (int rowindex = 0; rowindex < ds.Tables[0].Rows.Count; rowindex++)
                {
                    if (Convert.ToString(ds.Tables[0].Rows[rowindex][0]) != string.Empty)
                    {
                        _obj_Smhr_Positions.OPERATION       = operation.Check;
                        _obj_Smhr_Positions.POSITIONS_CODE  = Convert.ToString(ds.Tables[0].Rows[rowindex][0]);
                        _obj_Smhr_Positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                        if (Convert.ToString(BLL.get_Positions(_obj_Smhr_Positions).Rows[0]["Count"]) == "1")
                        {
                            IsCorrect = false;
                            rowno     = rowindex + 2;
                            columnno  = columnno + "," + "Name *";
                            errormsg  = "Position Name Is Already Exists  ";
                        }
                    }
                    if (Convert.ToString(ds.Tables[0].Rows[rowindex][2]) != string.Empty)
                    {
                        for (int count = 0; count < rcmb_PositionsJobs.Items.Count; count++)
                        {
                            if (Convert.ToString(ds.Tables[0].Rows[rowindex][2]) == rcmb_PositionsJobs.Items[count].Text)
                            {
                                found = true;
                                jobid = Convert.ToInt32(rcmb_PositionsJobs.Items[count].Value);
                            }
                        }
                        if (!found)
                        {
                            IsCorrect = false;
                            rowno     = rowindex + 2;
                            columnno  = columnno + "," + "Job";
                            if (errormsg != string.Empty)
                            {
                                errormsg = errormsg + "," + "Job Which You Have Entered Is Not Exists   ";
                            }
                            else
                            {
                                errormsg = "Job Which You Have Entered Is Not Exists   ";
                            }
                        }
                    }
                    if (Convert.ToString(ds.Tables[0].Rows[rowindex][3]) == string.Empty)
                    {
                        IsCorrect = false;
                        rowno     = rowindex + 2;
                        columnno  = columnno + "," + "Status *";
                        if (errormsg != string.Empty)
                        {
                            errormsg = errormsg + "," + "Job Status Should Be Active Or In Active   ";
                        }
                        else
                        {
                            errormsg = "Job Status Should Be Active Or In Active  ";
                        }
                    }
                    else
                    {
                        if (!((Convert.ToString(ds.Tables[0].Rows[rowindex][3]).ToUpper() == "ACTIVE") || (Convert.ToString(ds.Tables[0].Rows[rowindex][3]).ToUpper() == "INACTIVE")))
                        {
                            IsCorrect = false;
                            rowno     = rowindex + 2;
                            columnno  = columnno + "," + "Status *";
                            if (errormsg != string.Empty)
                            {
                                errormsg = errormsg + "," + "Job Status Should Be Active Or In Active   ";
                            }
                            else
                            {
                                errormsg = "Job Status Should Be Active Or In Active  ";
                            }
                        }
                    }
                    if ((Convert.ToString(ds.Tables[0].Rows[rowindex][4]) != string.Empty))
                    {
                        if (!(BLL.CheckDateFormat(Convert.ToString(ds.Tables[0].Rows[rowindex][4].ToString()))))
                        {
                            IsCorrect = false;
                            rowno     = rowindex + 2;
                            columnno  = columnno + "," + "Start Date *(DD/MM/YYYY)";
                            errormsg  = errormsg + "," + "Enter Start Date In The Correct Format  ";
                        }
                    }
                    else
                    {
                        IsCorrect = false;
                        rowno     = rowindex + 2;
                        columnno  = columnno + "," + "Start Date *(DD/MM/YYYY)";
                        errormsg  = errormsg + "," + "Enter Start Date   ";
                    }
                    if ((Convert.ToString(ds.Tables[0].Rows[rowindex][4]) != string.Empty) && (Convert.ToString(ds.Tables[0].Rows[rowindex][5]) != string.Empty))
                    {
                        bool stdatetime = true;
                        if (!(BLL.CheckDateFormat(Convert.ToString(ds.Tables[0].Rows[rowindex]["Start Date *(DD/MM/YYYY)"]))))
                        {
                            stdatetime = false;
                            IsCorrect  = false;
                            rowno      = rowindex + 2;
                            columnno   = columnno + "," + "Start Date *(DD/MM/YYYY)";
                            errormsg   = errormsg + "," + "Enter Correct Date Format For Start Date   ";
                            // break;
                        }

                        if (!(BLL.CheckDateFormat(Convert.ToString(ds.Tables[0].Rows[rowindex]["End Date (DD/MM/YYYY)"]))))
                        {
                            stdatetime = false;
                            IsCorrect  = false;
                            rowno      = rowindex + 2;
                            columnno   = columnno + "," + "End Date (DD/MM/YYYY)";
                            errormsg   = errormsg + "," + "Enter Correct Date Format For End Date   ";
                            //break;
                        }
                        if (!stdatetime)
                        {
                            if (!(Convert.ToDateTime(ds.Tables[0].Rows[rowindex][4].ToString()) > (Convert.ToDateTime(ds.Tables[0].Rows[rowindex][5].ToString()))))
                            {
                                IsCorrect = false;
                                rowno     = rowindex + 2;
                                columnno  = columnno + "," + "End Date (DD/MM/YYYY)";
                                columnno  = columnno + "," + "Start Date *(DD/MM/YYYY)";
                                errormsg  = errormsg + "," + "Start Date Should Be Greater Than End Date   ";
                            }
                        }
                    }
                    if (!IsCorrect)
                    {
                        DataRow newrow = dtfail.NewRow();
                        newrow["S.NO"]         = dtfail.Rows.Count + 1;
                        newrow["ROWNO"]        = rowno;
                        newrow["COLUMNS NAME"] = columnno;
                        dtfail.Rows.Add(newrow);
                        ds.Tables[0].Rows[rowindex]["Error Message"] = errormsg;
                    }
                    // For checking The Duplicate Row in Excel
                    for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
                    {
                        if (ds.Tables[0].Rows[rowindex]["Name *"].ToString().Trim() == ds.Tables[0].Rows[k]["Name *"].ToString().Trim())
                        {
                            if (rowindex != k)
                            {
                                errormsg  = errormsg + "," + " Position Name is repeated in Excel Sheet";
                                IsCorrect = false;
                                rowno     = rowindex + 2;
                                columnno  = "Name *";
                            }
                        }
                    }
                }
                if (dtfail.Rows.Count > 0)
                {
                    Session["dt_fail"] = dtfail;
                    Session["ds_data"] = ds;
                    Delete_Excel_File();
                    Telerik.Web.UI.RadWindow newwindow = new Telerik.Web.UI.RadWindow();
                    newwindow.ID                = "RadWindow_import";
                    newwindow.NavigateUrl       = "~/Masters/Importresult.aspx";
                    newwindow.Title             = "Import Job Process";
                    newwindow.Width             = 1150;
                    newwindow.Height            = 580;
                    newwindow.VisibleOnPageLoad = true;
                    if (RWM_POSITIONPOSTREPLY.Windows.Count > 1)
                    {
                        RWM_POSITIONPOSTREPLY.Windows.RemoveAt(1);
                    }
                    RWM_POSITIONPOSTREPLY.Windows.Add(newwindow);
                    RWM_POSITIONPOSTREPLY.Visible = true;
                    return;
                }
                else
                {
                    // For Dumping Each Record In To The Database
                    for (int xlrows = 0; xlrows < ds.Tables[0].Rows.Count; xlrows++)
                    {
                        _obj_Smhr_Positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                        _obj_Smhr_Positions.POSITIONS_CODE  = Convert.ToString(ds.Tables[0].Rows[xlrows][0]);
                        _obj_Smhr_Positions.POSITIONS_DESC  = Convert.ToString(ds.Tables[0].Rows[xlrows][1]);
                        if (Convert.ToString(ds.Tables[0].Rows[xlrows][2]) != string.Empty)
                        {
                            for (int count = 0; count < rcmb_PositionsJobs.Items.Count; count++)
                            {
                                if (Convert.ToString(ds.Tables[0].Rows[xlrows][2]) == rcmb_PositionsJobs.Items[count].Text)
                                {
                                    _obj_Smhr_Positions.POSITIONS_ID = Convert.ToInt32(rcmb_PositionsJobs.Items[count].Value);
                                    break;
                                }
                            }
                        }

                        if (Convert.ToString(ds.Tables[0].Rows[xlrows][2]) != string.Empty)
                        {
                            _obj_Smhr_Positions.POSITIONS_JOBSID = jobid;
                        }
                        if (Convert.ToString(ds.Tables[0].Rows[xlrows][3]) != string.Empty)
                        {
                            if (Convert.ToString(ds.Tables[0].Rows[xlrows][3]).ToUpper() == "ACTIVE")
                            {
                                _obj_Smhr_Positions.POSITIONS_STATUS = 0;
                            }
                            else
                            {
                                _obj_Smhr_Positions.POSITIONS_STATUS = 1;
                            }
                        }
                        string sdate = "";
                        string edate = "";
                        sdate = ds.Tables[0].Rows[xlrows][4].ToString();
                        edate = ds.Tables[0].Rows[xlrows][5].ToString();
                        bool wrongsdformat = sdate.Contains(".");
                        bool wrongedformat = edate.Contains(".");
                        if (wrongsdformat)
                        {
                            sdate = sdate.Replace(".", "/");
                        }
                        if (wrongedformat)
                        {
                            edate = edate.Replace(".", "/");
                        }

                        _obj_Smhr_Positions.SDATE = sdate;
                        _obj_Smhr_Positions.EDATE = edate;

                        _obj_Smhr_Positions.CREATEDBY   = Convert.ToInt32(Session["USER_ID"]);
                        _obj_Smhr_Positions.CREATEDDATE = DateTime.Now;

                        _obj_Smhr_Positions.LASTMDFBY       = Convert.ToInt32(Session["USER_ID"]);
                        _obj_Smhr_Positions.LASTMDFDATE     = DateTime.Now;
                        _obj_Smhr_Positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);

                        _obj_Smhr_Positions.OPERATION       = operation.Check;
                        _obj_Smhr_Positions.POSITIONS_CODE  = Convert.ToString(ds.Tables[0].Rows[xlrows][0]);
                        _obj_Smhr_Positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                        if (Convert.ToString(BLL.get_Positions(_obj_Smhr_Positions).Rows[0]["Count"]) == "1")
                        {
                            continue;
                            //IsCorrect = true;
                        }
                        else
                        {
                            _obj_Smhr_Positions.OPERATION = operation.Insert1;
                            if (BLL.set_Positions(_obj_Smhr_Positions))
                            {
                                IsCorrect = true;
                            }
                        }
                    }
                    Rm_PO_page.SelectedIndex = 0;
                    LoadGrid();
                    Rm_PO_page.DataBind();
                    if (IsCorrect)
                    {
                        BLL.ShowMessage(this, "Information Uploaded SuccessFully");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frmposition.aspx", ex.StackTrace, DateTime.Now);
            Response.Redirect("Frm_ErrorPage.aspx");
        }
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            SMHR_POSITIONS _obj_Smhr_Positions = new SMHR_POSITIONS();
            _obj_Smhr_Positions.POSITIONS_CODE  = BLL.ReplaceQuote(rtxt_PositionsCode.Text);
            _obj_Smhr_Positions.POSITIONS_DESC  = BLL.ReplaceQuote(rtxt_PositionsDesc.Text);
            _obj_Smhr_Positions.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"].ToString());

            _obj_Smhr_Positions.POSITIONS_JOBSID = Convert.ToInt32(rcmb_PositionsJobs.SelectedItem.Value);
            _obj_Smhr_Positions.POSITIONS_STATUS = Convert.ToInt32(rcmb_PositionsStatus.SelectedItem.Value);

            _obj_Smhr_Positions.STARTDATE = rdtp_PositionsStartDate.SelectedDate;
            _obj_Smhr_Positions.ENDDATE   = rdtp_PositionsEndDate.SelectedDate;


            _obj_Smhr_Positions.CREATEDBY   = Convert.ToInt32(Session["USER_ID"]); // ### Need to Get the Session
            _obj_Smhr_Positions.CREATEDDATE = DateTime.Now;

            _obj_Smhr_Positions.LASTMDFBY   = Convert.ToInt32(Session["USER_ID"]); // ### Need to Get the Session
            _obj_Smhr_Positions.LASTMDFDATE = DateTime.Now;

            switch (((Button)sender).ID.ToUpper())
            {
            case "BTN_EDIT":
                _obj_Smhr_Positions.POSITIONS_ID = Convert.ToInt32(lbl_PositionsID.Text);
                _obj_Smhr_Positions.OPERATION    = operation.Check;
                if (Convert.ToString(BLL.get_Positions(_obj_Smhr_Positions).Rows[0]["Count"]) != "1")
                {
                    //BLL.ShowMessage(this, "Position with this Name Already Exists");
                    //return;
                }
                _obj_Smhr_Positions.OPERATION = operation.Update;
                if (BLL.set_Positions(_obj_Smhr_Positions))
                {
                    BLL.ShowMessage(this, "Information Updated SuccessFully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Saved");
                }

                break;

            case "BTN_SAVE":
                _obj_Smhr_Positions.OPERATION = operation.Check;
                if (Convert.ToString(BLL.get_Positions(_obj_Smhr_Positions).Rows[0]["Count"]) != "0")
                {
                    BLL.ShowMessage(this, "Positions with this Name Already Exists");
                    return;
                }
                _obj_Smhr_Positions.OPERATION = operation.Insert;
                if (BLL.set_Positions(_obj_Smhr_Positions))
                {
                    BLL.ShowMessage(this, "Information Saved SuccessFully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Saved");
                }
                break;

            default:
                break;
            }
            Rm_PO_page.SelectedIndex = 0;
            LoadGrid();
            Rg_Positions.DataBind();
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frmPosition", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }