Esempio n. 1
0
    protected void lnk_genTemplateRpt_OnClick(object sender, EventArgs e)
    {
        lblErr1.Text = "";
        string _PY     = txtTempPlanYear.Text;
        bool   _exists = BenhierDAL.checkRatePY(_PY);

        if (_exists)
        {
            string msg         = "Rates for entered plan year already defined!";
            string alertScript = "<script language=JavaScript> alert('" + msg + "'); <" + "/script>";
            if (!ClientScript.IsClientScriptBlockRegistered("alert"))
            {
                ClientScript.RegisterClientScriptBlock(typeof(Page), "alert", alertScript);
            }
        }
        else
        {
            DataSet dsrptTemp1 = new DataSet(); dsrptTemp1.Clear();
            dsrptTemp1 = BenhierDAL.rateTemplate(_PY);
            string         filename   = "Rates_Template_" + _PY;
            string[]       sheetnames = { "rates" + _PY };
            string[][]     titles     = { new string[] { "" } };
            string[][]     colsFormat = { new string[] { "number", "string", "string", "string", "string", "string", "string", "decimal", "decimal", "number" } };
            int[][]        colsWidth  = { new int[] { 70, 100, 90, 70, 200, 80, 80, 75, 90, 100 } };
            CreateExcelRpt xlobj      = new CreateExcelRpt();
            xlobj.ExcelXMLRpt(dsrptTemp1, filename, sheetnames, titles, colsFormat, colsWidth, String.Empty);
        }
    }
Esempio n. 2
0
    protected void btn_import_Click(object sender, EventArgs e)
    {
        string strFilePath1 = "";

        lbl_error.Text  = "";
        lbl_result.Text = "";
        string _yr = txtTempPlanYearImp.Text;

        if (FileUpload1.GotFile && Page.IsValid)
        {
            try
            {
                bool _pycheck = BenhierDAL.checkRatePY(_yr);
                if (!_pycheck)
                {
                    string fn = System.IO.Path.GetFileName(FileUpload1.FilePost.FileName);
                    if (fn.Contains(_yr))
                    {
                        strFilePath1 = Server.MapPath("~/uploads/") + fn;
                        if (File.Exists(strFilePath1))
                        {
                            File.Delete(strFilePath1);
                        }

                        FileUpload1.FilePost.SaveAs(strFilePath1);
                        int _cnt = IPBAImport.importRatesTemplate(strFilePath1, _yr);
                        lbl_result.Text   = "Imported Rates successfully for year - " + _yr;
                        Session["taskId"] = Convert.ToInt32(Session["taskId"]) + 1;
                        Audit.auditUserTaskINRC(Session.SessionID, Session["mid"].ToString(), Session["taskId"].ToString(), "IPBA", "New Rates Import", "Rates", "New Rates", _yr, _cnt);
                    }
                    else
                    {
                        throw (new Exception("File Plan year doesn't match with entered Plan year!"));
                    }
                }
                else
                {
                    throw (new Exception("Rates for the entered Plan Year already defined!"));
                }
            }
            catch (Exception ex)
            {
                lbl_error.Text = "Error in importing file. " + ex.Message;
            }
            finally
            {
                FileUpload1.FilePost.InputStream.Flush();
                FileUpload1.FilePost.InputStream.Close();
                FileUpload1.FilePost.InputStream.Dispose();
                if (File.Exists(strFilePath1))
                {
                    File.Delete(strFilePath1);
                }
            }
        }
    }