Exemplo n.º 1
0
    protected void lnk_Edit_Command(object sender, CommandEventArgs e)
    {
        try
        {
            clearControls();
            rtxt_ExpenditureName.Enabled         = false;
            _obj_Smhr_Expenditure                = new SMHR_EXPENDITURE();
            _obj_Smhr_Expenditure.OPERATION      = operation.Get;
            _obj_Smhr_Expenditure.EXPENDITURE_ID = Convert.ToInt32(e.CommandArgument);
            DataTable dt = BLL.get_Expenditure(_obj_Smhr_Expenditure);
            lbl_ExpenditureID.Text    = dt.Rows[0]["EXPENDITURE_ID"].ToString();
            rtxt_ExpenditureName.Text = Convert.ToString(dt.Rows[0]["EXPENDITURE_NAME"]);
            rtxt_ExpenditureDesc.Text = Convert.ToString(dt.Rows[0]["EXPENDITURE_DESC"]);
            if (Convert.ToInt32(Session["WRITEFACILITY"]) == 2)
            {
                btn_Update.Visible = false;
            }

            else
            {
                btn_Update.Visible = true;
            }
            Rm_CY_page.SelectedIndex = 1;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_ExpenditureType", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
Exemplo n.º 2
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            _obj_Smhr_Expenditure = new SMHR_EXPENDITURE();
            _obj_Smhr_Expenditure.EXPENDITURE_NAME = BLL.ReplaceQuote(rtxt_ExpenditureName.Text);
            _obj_Smhr_Expenditure.EXPENDITURE_DESC = BLL.ReplaceQuote(rtxt_ExpenditureDesc.Text);
            _obj_Smhr_Expenditure.ORGANISATION_ID  = Convert.ToInt32(Session["ORG_ID"]);
            switch (((Button)sender).ID.ToUpper())
            {
            case "BTN_UPDATE":
                _obj_Smhr_Expenditure.EXPENDITURE_ID = Convert.ToInt32(lbl_ExpenditureID.Text);
                _obj_Smhr_Expenditure.OPERATION      = operation.Update;
                if (BLL.set_Expenditure(_obj_Smhr_Expenditure))
                {
                    BLL.ShowMessage(this, "Information Updated Successfully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Updated");
                }

                break;

            case "BTN_SAVE":
                _obj_Smhr_Expenditure.OPERATION = operation.Check;
                if (Convert.ToString(BLL.get_Expenditure(_obj_Smhr_Expenditure).Rows[0][0]) != "0")
                {
                    BLL.ShowMessage(this, "Expenditure Name Already Exists");
                    return;
                }
                _obj_Smhr_Expenditure.OPERATION = operation.Insert;
                if (BLL.set_Expenditure(_obj_Smhr_Expenditure))
                {
                    BLL.ShowMessage(this, "Information Saved Successfully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Saved");
                }
                break;

            default:
                break;
            }
            Rm_CY_page.SelectedIndex = 0;
            LoadGrid();
            Rg_Expenditure.DataBind();
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_ExpenditureType", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
Exemplo n.º 3
0
    public void LoadGrid()
    {
        try
        {
            _obj_Smhr_Expenditure                 = new SMHR_EXPENDITURE();
            _obj_Smhr_Expenditure.OPERATION       = operation.Select;
            _obj_Smhr_Expenditure.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
            DataTable DT = BLL.get_Expenditure(_obj_Smhr_Expenditure);
            Rg_Expenditure.DataSource = DT;

            clearControls();
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_ExpenditureType", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
Exemplo n.º 4
0
 private void BindExpenditure()
 {
     try
     {
         SMHR_EXPENDITURE _obj_smhr_expenditure = new SMHR_EXPENDITURE();
         _obj_smhr_expenditure.OPERATION       = operation.Select;
         _obj_smhr_expenditure.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
         DataTable dt = BLL.get_Expenditure(_obj_smhr_expenditure);
         radExpenditureName.DataSource     = dt;
         radExpenditureName.DataTextField  = "EXPENDITURE_NAME";
         radExpenditureName.DataValueField = "EXPENDITURE_ID";
         radExpenditureName.DataBind();
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_ServiceProviders", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
Exemplo n.º 5
0
 private void BindExpenditureNames()
 {
     try
     {
         SMHR_EXPENDITURE _obj_Smhr_Expenditure = new SMHR_EXPENDITURE();
         _obj_Smhr_Expenditure.OPERATION       = operation.Select2;
         _obj_Smhr_Expenditure.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
         DataTable dt = BLL.get_Expenditure(_obj_Smhr_Expenditure);
         rad_ExpenditureName.DataSource     = dt;
         rad_ExpenditureName.DataValueField = "EXPENDITURE_ID";
         rad_ExpenditureName.DataTextField  = "EXPENDITURE_NAME";
         rad_ExpenditureName.DataBind();
         rad_ExpenditureName.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("Select", "-1"));
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "MedicalBenifits", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
Exemplo n.º 6
0
    protected void lnk_Edit_Command(object sender, CommandEventArgs e)
    {
        try
        {
            int finPrdID = Convert.ToInt32(e.CommandArgument);
            lbl_ExpenditureID.Text = finPrdID.ToString();
            int count = 0;
            clearControls();
            BindFinancialPeriod();
            BindExpenditureNames();
            rad_ExpenditureName.Enabled  = false;
            RadGrid1.Visible             = true;
            smhr_MedicalBenfit           = new SMHR_MEDICALBENFIT();
            smhr_MedicalBenfit.OPERATION = operation.Get;
            smhr_MedicalBenfit.OrgID     = Convert.ToInt32(Session["ORG_ID"]);
            //smhr_MedicalBenfit.ExpendID = lbl_ExpenditureID.Text;
            smhr_MedicalBenfit.FinancialPeriodID = finPrdID;
            DataTable dt = BLL.get_MedicalBenfit(smhr_MedicalBenfit);
            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
            if (dt.Rows.Count > 0)
            {
                SMHR_EXPENDITURE _obj_Smhr_Expenditure = new SMHR_EXPENDITURE();
                _obj_Smhr_Expenditure.OPERATION       = operation.Select;
                _obj_Smhr_Expenditure.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);

                /*rad_ExpenditureName.DataSource = BLL.get_Expenditure(_obj_Smhr_Expenditure);
                 * rad_ExpenditureName.DataValueField = "EXPENDITURE_ID";
                 * rad_ExpenditureName.DataTextField = "EXPENDITURE_NAME";
                 * rad_ExpenditureName.DataBind();
                 * rad_ExpenditureName.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("Select", "-1"));
                 * rad_ExpenditureName.SelectedIndex = rad_ExpenditureName.FindItemIndexByValue(smhr_MedicalBenfit.ExpendID.ToString());*/
                radFinPeriod.SelectedIndex = radFinPeriod.FindItemIndexByValue(dt.Rows[0]["MEDICALBENFIT_FIN_PERIOD_ID"].ToString());
            }
            SMHR_PERIOD osmhr_period = new SMHR_PERIOD();
            osmhr_period.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
            osmhr_period.PERIOD_ID       = Convert.ToInt32(radFinPeriod.SelectedValue);
            DataTable dtCurrentFinPeriod = BLL.IscurrentFinPeriod(osmhr_period);

            if (string.Compare(dtCurrentFinPeriod.Rows[0]["ISEXISTS"].ToString(), "0", true) == 0)
            {
                RadGrid1.Enabled = false;
            }
            else
            {
                RadGrid1.Enabled = true;
            }
            // trExpend.Visible = false;

            // rad_ExpenditureName.Text = Convert.ToString(dt.Rows[0]["EXPENDITURE_NAME"]);
            //  rad_ExpenditureName.Enabled = false;
            // rtxt_ExpenditureDesc.Text = Convert.ToString(dt.Rows[0]["EXPENDITURE_DESC"]);
            if (Convert.ToInt32(Session["WRITEFACILITY"]) == 2)
            {
                btn_Update.Visible = false;
            }
            else
            {
                btn_Update.Visible = true;
            }
            Rm_CY_page.SelectedIndex = 1;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToBoolean(dt.Rows[i]["MEDICAL_ADDED"]) == false)
                {
                    count++;
                }
            }
            if (count > 0)
            {
                RadGrid1.MasterTableView.Columns[3].Visible = false;
            }
            else
            {
                RadGrid1.MasterTableView.Columns[3].Visible = true;
            }
            radFinPeriod.Enabled = false;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "MedicalBenifits", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
    private void ValidateData(out SMHR_MedicalInvoice oSMHR_MedicalInvoice, out bool result)
    {
        try
        {
            result = true;
            oSMHR_MedicalInvoice = new SMHR_MedicalInvoice();
            string strfilename = Guid.NewGuid().ToString() + FBrowse.FileName;
            strfilename2 = strfilename;
            if (FBrowse.HasFile)
            {
                FBrowse.PostedFile.SaveAs(Server.MapPath("~/MedicalInvoice/") + strfilename);
            }
            else
            {
                result = false;
                BLL.ShowMessage(this, "Please Select the File to upload");
                return;
            }

            string    strpath     = Server.MapPath("~/MedicalInvoice/") + strfilename;
            string    ExcelPath   = System.Configuration.ConfigurationManager.AppSettings["ExcelPath"];//"Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;";
            string    strcon      = ExcelPath + "Data Source='" + strpath + "';";
            DataTable dtExcelData = GetDatafromExcel(strcon);

            if (dtExcelData != null && ValidateHeader(dtExcelData))
            {
                if (dtExcelData.Rows.Count != 0)
                {
                    oSMHR_MedicalInvoice.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                    oSMHR_MedicalInvoice.OPERATION       = operation.Check;
                    DataTable dtBenficaryDetails = BLL.get_MedicalInvoice(oSMHR_MedicalInvoice);
                    oSMHR_MedicalInvoice.OPERATION = operation.Validate;
                    DataTable        dtInvoiceValidate = BLL.get_MedicalInvoice(oSMHR_MedicalInvoice);
                    DataTable        dtInvoices        = CreateInvoiceTable();
                    SMHR_EXPENDITURE oSMHR_EXPENDITURE = new SMHR_EXPENDITURE();
                    oSMHR_EXPENDITURE.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                    oSMHR_EXPENDITURE.OPERATION       = operation.Select;
                    DataTable dtexpenditures = BLL.get_Expenditure(oSMHR_EXPENDITURE);
                    foreach (DataRow record in dtExcelData.Rows)
                    {
                        if (!string.IsNullOrEmpty(record["Beneficiary Name"].ToString().Trim()))
                        {
                            if (dtBenficaryDetails.Select("BenficaryName='" + record["Beneficiary Name"].ToString().Trim() + "'").Length == 0)
                            {
                                Delete_Excel_File();
                                result = false;
                                BLL.ShowMessage(this, "Benficary Name not exists");
                                return;
                            }
                        }
                        else
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Benficary Name should not be empty");
                            return;
                        }

                        if (string.IsNullOrEmpty(record["Invoice ID"].ToString().Trim()))
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Invoice ID should not be empty");
                            return;
                        }
                        if (string.IsNullOrEmpty(record["Invoice Date"].ToString().Trim()))
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Invoice Date should not be empty");
                            return;
                        }
                        if (string.IsNullOrEmpty(record["Staff Name"].ToString().Trim()))
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Staff Name should not be empty");
                            return;
                        }
                        if (!string.IsNullOrEmpty(record["Exp Name"].ToString().Trim()))
                        {
                            if (dtexpenditures.Select("expenditure_name='" + record["Exp Name"].ToString().Trim() + "'").Length == 0)
                            {
                                Delete_Excel_File();
                                result = false;
                                BLL.ShowMessage(this, "Exp Name not exists");
                                return;
                            }
                        }
                        else
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Exp Name should not be empty");
                            return;
                        }
                        if (!string.IsNullOrEmpty(record["Service Provider"].ToString().Trim()) && string.Compare(record["Service Provider"].ToString().Trim(), "Select", true) != 0)
                        {
                            if (string.Compare(record["Service Provider"].ToString().Trim(), RadServiceProviderName.SelectedItem.Text.Trim(), true) != 0)
                            {
                                Delete_Excel_File();
                                result = false;
                                BLL.ShowMessage(this, "Service Provider mismatch");
                                return;
                            }
                        }
                        else
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Service Provider should not be empty");
                            return;
                        }
                        if (!string.IsNullOrEmpty(record["Amount"].ToString().Trim()))
                        {
                            double d;
                            if (!double.TryParse(record["Amount"].ToString().Trim(), out d))
                            {
                                Delete_Excel_File();
                                result = false;
                                BLL.ShowMessage(this, "Amount should be a number");
                                return;
                            }
                        }
                        else
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Amount should not be empty");
                            return;
                        }
                        if (dtInvoiceValidate.Select("SERVICEPROVIDERNAME='" + record["Service Provider"].ToString().Trim() + "' and INVOICEID='" + record["Invoice ID"].ToString().Trim() + "'").Length > 0)
                        {
                            Delete_Excel_File();
                            result = false;
                            BLL.ShowMessage(this, "Invoice ID already exists");
                            return;
                        }
                        DateTime drt = new DateTime();
                        try
                        {
                            drt = Convert.ToDateTime(record[1].ToString());
                        }
                        catch (Exception ex)
                        {
                            result = false;
                            BLL.ShowMessage(this, "Date Format should be mm/dd/yyyy");
                        }
                        dtInvoices.Rows.Add(record[0].ToString(), drt.ToString("MM/dd/yyyy"), record[2].ToString(), record[3].ToString(), record[4].ToString(), record[5].ToString(), record[6].ToString());
                    }
                    //if (dtInvoices.Select("Invoice ID='" + record["Exp Name"].ToString().Trim() + "'").Length == 0)
                    //{
                    //}
                    oSMHR_MedicalInvoice.ServiceProviderID = Convert.ToInt32(RadServiceProviderName.SelectedValue);
                    oSMHR_MedicalInvoice.InvoiceDoc        = "~/MedicalInvoice/" + strfilename;
                    oSMHR_MedicalInvoice.MedicalInvoice    = dtInvoices;
                    oSMHR_MedicalInvoice.CREATEDBY         = Convert.ToInt32(Session["USER_ID"]);
                    oSMHR_MedicalInvoice.CREATEDDATE       = DateTime.Now;
                    oSMHR_MedicalInvoice.ORGANISATION_ID   = Convert.ToInt32(Session["ORG_ID"]);
                }
                else
                {
                    Delete_Excel_File();
                    result = false;
                    BLL.ShowMessage(this, "There are no records to load");
                    return;
                }
            }
            else
            {
                Delete_Excel_File();
                result = false;
                BLL.ShowMessage(this, "Header mismatch");
                return;
            }
        }

        catch (Exception ex)
        {
            throw ex;
        }
    }