protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            oSMHR_MedicalInvoice = new SMHR_MedicalInvoice();
            bool result = true;
            ValidateData(out oSMHR_MedicalInvoice, out result);
            if (result)
            {
                oSMHR_MedicalInvoice.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                switch (((Button)sender).ID.ToUpper())
                {
                case "BTN_EDIT":
                    oSMHR_MedicalInvoice.InvoiceDocID = Convert.ToInt32(lbl_InvoiceDocID.Text);
                    oSMHR_MedicalInvoice.OPERATION    = operation.Update;
                    if (BLL.set_MedicalInvoice(oSMHR_MedicalInvoice))
                    {
                        BLL.ShowMessage(this, "Information Updated Successfully");
                    }
                    else
                    {
                        BLL.ShowMessage(this, "Information Not Saved");
                    }


                    break;

                case "BTN_SAVE":

                    oSMHR_MedicalInvoice.OPERATION = operation.Insert;
                    if (BLL.set_MedicalInvoice(oSMHR_MedicalInvoice))
                    {
                        BLL.ShowMessage(this, "Information Saved Successfully");
                    }
                    else
                    {
                        BLL.ShowMessage(this, "Information Not Saved");
                    }
                    break;

                default:
                    break;
                }
                Rm_CG_page.SelectedIndex = 0;
                LoadGrid();
                Rg_Categories.DataBind();
            }
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "UploadInvoice", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
Beispiel #2
0
    protected void Btn_Imp_Category_click(object sender, EventArgs e)
    {
        try
        {
            //written by Rajasekhar
            //To Import category Excel Sheet

            string strcon = null;

            string strfilename1 = FileUpload1.FileName;
            strfilename2 = Convert.ToString(DateTime.Now.TimeOfDay) + "_" + strfilename1;
            strfilename2 = strfilename2.Replace("/", "").Replace(":", ".");
            if (FileUpload1.HasFile)
            {
                if (System.IO.Directory.Exists(Server.MapPath("~/IMPORT_EXCEL/")) == false)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("~/IMPORT_EXCEL/"));
                }



                FileUpload1.PostedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/IMPORT_EXCEL/"), strfilename2));
                string   filename1 = Server.MapPath("~/IMPORT_EXCEL/") + ("") + (Convert.ToString(strfilename2));
                FileInfo fileInfo  = new FileInfo(filename1);
                if (fileInfo.Exists)
                {
                    string path = MapPath(strfilename1);
                    // string name = Path.GetFileName( path );
                    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(strfilename2));
                            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 + strfilename2;


            // 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_chk2 = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            string    sheetname;
            if (dt_chk2 == null)
            {
                objConn.Close();
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            else
            {
                sheetname = Convert.ToString(dt_chk2.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 errormsg = string.Empty;

            string projecttype = null;
            Int32  rowno       = 0;

            DateTime dat;
            string   columnno   = null;
            string   projname   = null;
            Boolean  filestatus = true;
            dtfail.Columns.Add("S.NO", typeof(Int32));
            dtfail.Columns.Add("ROWNO", typeof(Int32));
            dtfail.Columns.Add("COLUMNS NAMES", typeof(string));

            if (ds.Tables[0].Columns[0].ToString().Trim() == "Name*")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[1].ToString().Trim() == "Description")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }

            if (ds.Tables[0].Columns[2].ToString().Trim() == "OverTime Enabled")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[3].ToString().Trim() == "Bank Info")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[4].ToString().Trim() == "Currency")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[5].ToString().Trim() == "Age")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[6].ToString().Trim() == "DateFormat")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[7].ToString().Trim() == "Address")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[8].ToString().Trim() == "Country")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[9].ToString().Trim() == "Fiscal Year")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[10].ToString().Trim() == "Calendar")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[11].ToString().Trim() == "Payment Methods")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Columns[12].ToString().Trim() == "Localisation")
            {
            }
            else
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Please select the Correct Excel Template  Sheet.");
                return;
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                Delete_Excel_File();
                BLL.ShowMessage(this, "Successfully processed Excel file. No Records are Imported.");
                return;
            }

            //to check the data in excel
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                errormsg = string.Empty;
                columnno = string.Empty;
                if (ds.Tables[0].Rows[i]["Name*"].ToString().Trim() != "")
                {
                    _obj_Smhr_Category = new SMHR_CATEGORY();
                    _obj_Smhr_Category.CATEGORY_CODE   = Convert.ToString(ds.Tables[0].Rows[i]["Name*"]).Trim();
                    _obj_Smhr_Category.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                    _obj_Smhr_Category.OPERATION       = operation.Check;
                    if (Convert.ToString(BLL.get_Category(_obj_Smhr_Category).Rows[0]["Count"]) != "0")
                    {
                        // BLL.ShowMessage(this, "Category with this Name Already Exists");
                        // return;
                        errormsg   = "Category with this Name Already Exists";
                        filestatus = false;
                        rowno      = i + 2;
                        columnno   = "Name*";
                    }
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = "Name*";
                }
                for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
                {
                    if (ds.Tables[0].Rows[i]["Name*"].ToString().Trim() == ds.Tables[0].Rows[k]["Name*"].ToString().Trim())
                    {
                        if (i != k)
                        {
                            errormsg   = "Category with this Name is repeated in Excel Sheet";
                            filestatus = false;
                            rowno      = i + 2;
                            columnno   = "Name*";
                        }
                    }
                }

                if (ds.Tables[0].Rows[i]["Description"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Description";
                }
                if (ds.Tables[0].Rows[i]["OverTime Enabled"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "OverTime Enabled";
                }
                if (ds.Tables[0].Rows[i]["Bank Info"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Bank Info";
                }
                if (ds.Tables[0].Rows[i]["Currency"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Currency";
                }
                if (ds.Tables[0].Rows[i]["Age"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Age";
                }
                if (ds.Tables[0].Rows[i]["DateFormat"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "DateFormat";
                }
                if (ds.Tables[0].Rows[i]["Address"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Address";
                }
                if (ds.Tables[0].Rows[i]["Country"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Country";
                }
                if (ds.Tables[0].Rows[i]["Fiscal Year"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Fiscal Year";
                }
                if (ds.Tables[0].Rows[i]["Calendar"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Calendar";
                }
                if (ds.Tables[0].Rows[i]["Payment Methods"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Payment Methods";
                }
                if (ds.Tables[0].Rows[i]["Localisation"].ToString().Trim() != "")
                {
                }
                else
                {
                    filestatus = false;
                    rowno      = i + 2;
                    columnno   = columnno + "," + "Localisation";
                }
                if (filestatus == false)
                {
                    DataRow newrow = dtfail.NewRow();
                    newrow["S.NO"] = dtfail.Rows.Count + 1;


                    newrow["ROWNO"]         = rowno;
                    newrow["COLUMNS NAMES"] = columnno;
                    dtfail.Rows.Add(newrow);
                    ds.Tables[0].Rows[i]["Error Message"] = errormsg;
                }
            }
            if (dtfail.Rows.Count > 0)
            {
                Session["dt_fail"] = dtfail;
                Session["ds_data"] = ds;
                Delete_Excel_File();
                //LinkButton lnk_Import_process = (LinkButton)RadPanelBar1.FindItemByValue("AddAttachment").FindControl("lnk_Import_process");
                Telerik.Web.UI.RadWindow newwindow = new Telerik.Web.UI.RadWindow();
                // RWM_POSTREPLY.Windows.Remove(newwindow);
                newwindow.ID = "RadWindow_import";

                newwindow.NavigateUrl       = "~/Payroll/frm_AttendanceImportProcess.aspx";
                newwindow.Title             = "Import Process";
                newwindow.Width             = 1150;
                newwindow.Height            = 580;
                newwindow.VisibleOnPageLoad = true;
                if (RWM_POSTREPLY1.Windows.Count > 1)
                {
                    RWM_POSTREPLY1.Windows.RemoveAt(1);
                }
                RWM_POSTREPLY1.Windows.Add(newwindow);



                RWM_POSTREPLY1.Visible = true;
                return;
            }
            else
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    bool status = false;
                    _obj_Smhr_Category.CATEGORY_CODE           = Convert.ToString(ds.Tables[0].Rows[i]["Name*"]).Trim();
                    _obj_Smhr_Category.CATEGORY_DESC           = Convert.ToString(ds.Tables[0].Rows[i]["Description"]).Trim();
                    _obj_Smhr_Category.CATEGORY_ISOVERTIME     = Convert.ToBoolean(ds.Tables[0].Rows[i]["OverTime Enabled"]);
                    _obj_Smhr_Category.CATEGORY_NEEDBANKINFO   = Convert.ToBoolean(ds.Tables[0].Rows[i]["Bank Info"]);
                    _obj_Smhr_Category.ORGANISATION_ID         = Convert.ToInt32(Session["ORG_ID"]);
                    _obj_Smhr_Category.CATEGORY_ISFISCALYEAR   = Convert.ToBoolean(ds.Tables[0].Rows[i]["Fiscal Year"]);
                    _obj_Smhr_Category.CATEGORY_ISCURRENCY     = Convert.ToBoolean(ds.Tables[0].Rows[i]["Currency"]);
                    _obj_Smhr_Category.CATEGORY_ISDATEFORMAT   = Convert.ToBoolean(ds.Tables[0].Rows[i]["DateFormat"]);
                    _obj_Smhr_Category.CATEGORY_ISCOUNTRY      = Convert.ToBoolean(ds.Tables[0].Rows[i]["Country"]);
                    _obj_Smhr_Category.CATEGORY_ISADDRESS      = Convert.ToBoolean(ds.Tables[0].Rows[i]["Address"]);
                    _obj_Smhr_Category.CATEGORY_ISAGE          = Convert.ToBoolean(ds.Tables[0].Rows[i]["Age"]);
                    _obj_Smhr_Category.CATEGORY_ISPAYMENTMODE  = Convert.ToBoolean(ds.Tables[0].Rows[i]["Payment Methods"]);
                    _obj_Smhr_Category.CATEGORY_ISCALENDERYEAR = Convert.ToBoolean(ds.Tables[0].Rows[i]["Calendar"]);
                    _obj_Smhr_Category.CATEGORY_LOCALISATION   = Convert.ToBoolean(ds.Tables[0].Rows[i]["Localisation"]);

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

                    _obj_Smhr_Category.LASTMDFBY       = Convert.ToInt32(Session["USER_ID"]); // ### Need to Get the Session
                    _obj_Smhr_Category.LASTMDFDATE     = DateTime.Now;
                    _obj_Smhr_Category.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                    _obj_Smhr_Category.OPERATION       = operation.Insert;
                    status = BLL.set_Category(_obj_Smhr_Category);

                    if (status == true)
                    {
                        BLL.ShowMessage(this, "Information Saved Successfully");
                    }
                    ////else
                    ////    BLL.ShowMessage(this, "Information Not Saved");
                }
                LoadGrid();

                Rg_Categories.DataBind();
            }
        }

        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_Catagory", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
Beispiel #3
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            _obj_Smhr_Category = new SMHR_CATEGORY();
            _obj_Smhr_Category.CATEGORY_CODE           = rtxt_CategoryCode.Text.Replace("'", "''");
            _obj_Smhr_Category.CATEGORY_DESC           = rtxt_CategoryDesc.Text.Replace("'", "''");
            _obj_Smhr_Category.CATEGORY_ISOVERTIME     = chk_CategoryOverTime.Checked;
            _obj_Smhr_Category.CATEGORY_NEEDBANKINFO   = chk_CategoryNeedBankInfo.Checked;
            _obj_Smhr_Category.ORGANISATION_ID         = Convert.ToInt32(Session["ORG_ID"]);
            _obj_Smhr_Category.CATEGORY_ISFISCALYEAR   = chk_CategoryFiscalYearNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISCURRENCY     = chk_CategoryCurrencyNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISDATEFORMAT   = chk_CategoryDateFormatNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISCOUNTRY      = chk_CategoryCountryNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISADDRESS      = chk_CategoryAddressNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISAGE          = chk_CategoryAgeNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISPAYMENTMODE  = chk_CategoryPaymentMethodsNeeded.Checked;
            _obj_Smhr_Category.CATEGORY_ISCALENDERYEAR = chk_CategoryCalendarYear.Checked;
            _obj_Smhr_Category.CATEGORY_LOCALISATION   = chk_Localisation.Checked;

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

            _obj_Smhr_Category.LASTMDFBY       = Convert.ToInt32(Session["USER_ID"]); // ### Need to Get the Session
            _obj_Smhr_Category.LASTMDFDATE     = DateTime.Now;
            _obj_Smhr_Category.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
            switch (((Button)sender).ID.ToUpper())
            {
            case "BTN_EDIT":
                _obj_Smhr_Category.CATEGORY_ID = Convert.ToInt32(lbl_CategoryID.Text);
                _obj_Smhr_Category.OPERATION   = operation.Check;
                if (Convert.ToString(BLL.get_Category(_obj_Smhr_Category).Rows[0]["Count"]) != "1")
                {
                    BLL.ShowMessage(this, "Category with this Name Already Exists");
                    return;
                }
                _obj_Smhr_Category.OPERATION = operation.Update;
                if (BLL.set_Category(_obj_Smhr_Category))
                {
                    BLL.ShowMessage(this, "Information Updated Successfully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Saved");
                }


                break;

            case "BTN_SAVE":
                _obj_Smhr_Category.OPERATION = operation.Check;
                if (Convert.ToString(BLL.get_Category(_obj_Smhr_Category).Rows[0]["Count"]) != "0")
                {
                    BLL.ShowMessage(this, "Category with this Name Already Exists");
                    return;
                }
                _obj_Smhr_Category.OPERATION = operation.Insert;
                if (BLL.set_Category(_obj_Smhr_Category))
                {
                    BLL.ShowMessage(this, "Information Saved Successfully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Saved");
                }
                break;

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