Ejemplo n.º 1
0
    protected void Gridreqinfo_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "edit1")
        {
            int DocumentId = Convert.ToInt32(e.CommandArgument);
            int rst        = clsDocument.InsertDocumentLog(DocumentId, Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(System.DateTime.Now), false, false, false, true, false, false, false, false);

            string te = "DocumentEditAndView.aspx?id=" + DocumentId + "&&return=3";
            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "window.open('" + te + "');", true);
        }
        if (e.CommandName == "delete1")
        {
            int DocumentId = Convert.ToInt32(e.CommandArgument);
            hdncnfm.Value = DocumentId.ToString();
            imgconfirmok_Click(sender, e);
            // mdlpopupconfirm.Show();
        }
    }
    protected void imgbtnupdate_Click(object sender, EventArgs e)
    {
        //  Response.Write( ViewState["docId"] + " :: " + Convert.ToDecimal(txtnetamount.Text).ToString());

        Int32 rst  = clsDocument.UpdateDocumentMaster(Convert.ToInt32(ViewState["docId"]), Convert.ToInt32(ddldoctype.SelectedValue), 2, Convert.ToDateTime(lblUploadDate.Text), ViewState["decname"].ToString(), txtdoctitle.Text, txtdocdscrptn.Text, Convert.ToInt32(ddlpartyname.SelectedValue), txtdocrefnmbr.Text, Convert.ToDecimal(txtnetamount.Text), Convert.ToDateTime(txtDate.Text), ddldt.SelectedValue, txtpartdocrefno.Text);
        int   rst1 = clsDocument.InsertDocumentLog(Convert.ToInt32(ViewState["docId"]), Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(System.DateTime.Now), false, false, false, true, false, false, false, false);

        if (rst > 0)
        {
            bool fnws   = clsDocument.UpdateDocumentDateDetail(Convert.ToInt32(ViewState["docId"]), Convert.ToDateTime(txtDate.Text));
            int  rst111 = clsDocument.InsertDocumentLog(Convert.ToInt32(ViewState["docId"]), Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(System.DateTime.Now), false, false, false, true, false, false, false, false);
            pnlmsg.Visible = true;
            lblmsg.Text    = "Document Updated Successfully.";
            lblmsg.Visible = true;
            fillen(true);
            btncon.Visible       = true;
            imgbtnupdate.Visible = false;
        }
    }
    protected void grdDocList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "edit1")
        {
            int DocumentId = Convert.ToInt32(e.CommandArgument);
            int rst        = clsDocument.InsertDocumentLog(DocumentId, Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(System.DateTime.Now), false, false, false, true, false, false, false, false);
            Response.Redirect("DocumentEditBeforeAllocateApprove.aspx?id=" + DocumentId + "&&return=1");
        }
        if (e.CommandName == "delete1")
        {
            int DocumentId = Convert.ToInt32(e.CommandArgument);
            hdncnfm.Value = DocumentId.ToString();

            mdlpopupconfirm.Show();
        }
    }
Ejemplo n.º 4
0
    protected void imgbtnupload_Click(object sender, EventArgs e)
    {
        try
        {
            if (ddlpartyname.SelectedIndex > 0)
            {
                hdbPartyId.Value = (ddlpartyname.SelectedValue.ToString());
            }
            else
            {
                hdbPartyId.Value = "0";
            }
            if (ddldoctype.SelectedIndex > -1)
            {
                hdbDId.Value = ddldoctype.SelectedValue.ToString();
            }
            else
            {
                hdbDId.Value = "0";
            }
            double mul = 1073741824;

            plansize = 1;

            double sizeinbytes = mul * plansize;
            string str         = "";
            str = Server.MapPath("~\\Account\\" + Session["comid"] + "\\UploadedDocuments");

            string Location22 = Server.MapPath("~//Account//" + Session["comid"] + "//UploadedDocumentsTemp//");
            long   size       = GetFolderSize(str, false);
            hdnSIZEofFOLDER.Value = size.ToString();


            if (fileuploadocurl.HasFile)
            {
                double foldsize    = Convert.ToDouble(hdnSIZEofFOLDER.Value);
                double hasfilesize = Convert.ToDouble(fileuploadocurl.PostedFile.ContentLength.ToString());

                double totalsize = foldsize + hasfilesize;
                bool   access    = UserAccess.Usercon("DocumentMaster", "", "DocumentId", "", "", "CID", "DocumentMaster");
                if (access == true)
                {
                    //if (totalsize <= sizeinbytes)
                    //{
                    string filename = DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + "@" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "_" + fileuploadocurl.FileName.Replace(" ", "_");
                    ViewState["filename"] = filename;

                    fileuploadocurl.PostedFile.SaveAs(Server.MapPath("~\\Account\\" + Session["comid"] + "\\UploadedDocuments\\") + filename);
                    flnam = filename;

                    string path2 = Server.MapPath("~\\Account\\" + Session["comid"] + "\\UploadedDocuments\\" + filename.ToString());

                    ViewState["filp"] = path2;
                    string filexten = Path.GetExtension(path2);

                    Int32 rst = clsDocument.InsertDocumentMaster(Convert.ToInt32(ddldoctype.SelectedValue), 2, Convert.ToDateTime(System.DateTime.Now.ToString()), filename.ToString(), txtdoctitle.Text, txtdocdscrptn.Text, Convert.ToInt32(ddlpartyname.SelectedValue), txtdocrefnmbr.Text, Convert.ToDecimal(txtnetamount.Text), Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(TxtDocDate.Text), filexten);
                    if (rst > 0)
                    {
                        string Location12 = Server.MapPath("~//Account//" + Session["comid"] + "//DocumentImage//");
                        Array  file1;
                        int    nooffile1 = 0;
                        file1     = Directory.GetFiles(Location12);
                        nooffile1 = file1.Length;
                        //  Response.Write(nooffile1);
                        ViewState["rst"] = rst.ToString();
                        bool st = Chkautoprcss.Checked;
                        if (st.ToString() == "True")
                        {
                            bool dcaprv = true;
                            //bool indc = clsDocument.insertDocumentProcessingnew(Convert.ToInt32(Session["AdminEmpId"]), rst, dcaprv);
                            bool indc = clsDocument.insertDocumentProcessingnew(Convert.ToInt32(Session["EmployeeId"]), rst, dcaprv);
                        }
                        bool fnws = clsDocument.UpdateDocumentDateDetail(rst, Convert.ToDateTime(TxtDocDate.Text));
                        lblmsg.Visible = true;
                        //   pnlmsg.Visible = true;
                        int rsts = clsDocument.InsertDocumentLog(rst, Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(System.DateTime.Now), false, false, true, false, false, false, false, false);

                        //  System.IO.File.Move(str + filename, Location22 + filename);
                        lblmsg.Text = "Document Uploaded Successfully.";

                        //string[] ag=new string[0];
                        //Main(ag);
                        string Location = Server.MapPath("~//Account//" + Session["comid"] + "//UploadedDocuments//");
                        string Location2 = Server.MapPath("~//Account//" + Session["comid"] + "//UploadedDocumentsTemp//");
                        string ss = "", ss1 = "";
                        //string Location2 = "TestOutput/test2";
                        sendaccessmail();

                        System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Location);
                        bool cof = false;
                        foreach (System.IO.FileInfo f in dir.GetFiles("*.pdf"))
                        {
                            if (System.IO.File.GetAttributes(Location + f.Name).ToString() != System.IO.FileAttributes.Hidden.ToString())
                            {
                                if (flnam != "")
                                {
                                    if (f.Name.ToString() == flnam)
                                    {
                                        cof = true;
                                        string filepath = Server.MapPath("~//Account//pdftoimage.exe");
                                        System.Diagnostics.ProcessStartInfo pti = new System.Diagnostics.ProcessStartInfo(filepath);
                                        //string flpt = "D:\\Capman.ifilecabinet.com1\\Account\\test.txt";
                                        //pti.FileName = Server.MapPath("~//Account//pdftoimage.exe");
                                        pti.UseShellExecute = false;
                                        //pti.Arguments = "@"+Server.MapPath("~//Account//") + "pdftoimage -i UploadedDocuments//" + f.Name + " " + "-o" + " " + "DocumentImage//";
                                        //pti.Arguments = filepath;
                                        //pti.Arguments += " "+ "-r" + " " + "VNKSURDLWQOVHPGH";
                                        // pti.Arguments += " " + " -i UploadedDocuments//" + f.Name + " " + "-o" + " " + "DocumentImage//";//+ " " + "-r" + "VNKSURDLWQOVHPGH";
                                        pti.Arguments = filepath + " -i UploadedDocuments//" + f.Name + " " + "-o" + " " + "DocumentImage//";    //+ " " + "-r" + "VNKSURDLWQOVHPGH";

                                        //pdftoimage.exe= -r XIWMOMMTAGFCFDMD;
                                        filepath += " " + "-r" + " " + "XIWMOMMTAGFCFDMD";
                                        pti.RedirectStandardOutput = true;
                                        pti.RedirectStandardInput  = true;
                                        pti.RedirectStandardError  = true;
                                        //pti.WorkingDirectory = "D:\\Capman.ifilecabinet.com1\\Account\\";
                                        pti.WorkingDirectory = Server.MapPath("~//Account//" + Session["comid"] + "//");
                                        System.Diagnostics.Process ps = Process.Start(pti);

                                        if (System.IO.File.Exists(Location + f.Name))
                                        {
                                        }
                                        else
                                        {
                                            System.IO.File.Copy(Location2 + f.Name, Location + f.Name);
                                        }
                                        // System.IO.File.SetAttributes(Location2 + f.Name, System.IO.FileAttributes.Hidden);
                                    }
                                }
                            }
                        }

                        if (cof == false)
                        {
                            if (System.IO.File.Exists(Location2 + flnam))
                            {
                            }
                            else
                            {
                                System.IO.File.Copy(Location + flnam, Location2 + flnam);
                            }
                            System.IO.File.SetAttributes(Location + flnam, System.IO.FileAttributes.Hidden);
                        }



                        if (Chkautoprcss.Checked == false)
                        {
                            bool      insdata;
                            DataTable dtt    = new DataTable();
                            DataTable DtMain = new DataTable();
                            //DtMain = ClsCompany.selectCompanyMaster();
                            //if (DtMain.Rows.Count > 0)
                            //{
                            //    bool st1 = Convert.ToBoolean(DtMain.Rows[0]["AutoAllocation"].ToString());
                            //    if (st1.ToString() == "True")
                            //    {
                            dtt = new DataTable();
                            dtt = ClsCompany.selectAutoAllocationMaster(ddlbusiness.SelectedValue);
                            if (dtt.Rows.Count > 0)
                            {
                                foreach (DataRow drr in dtt.Rows)
                                {
                                    Int32 empid = 0;
                                    empid = Convert.ToInt32(drr["EmployeeId"].ToString());

                                    insdata = false;

                                    insdata = clsDocument.insertDocumentProcessing(empid, rst);
                                }
                            }
                            //    }
                            //}
                        }
                        if (Request.QueryString["rrspd"] != null)
                        {
                            string     strc = "Update F1_F2_TaxDedctionTbl Set RRSPDoc='" + rst + "' where Id='" + Request.QueryString["rrspd"] + "'";
                            SqlCommand cmaq = new SqlCommand(strc, con);
                            if (con.State.ToString() != "Open")
                            {
                                con.Open();
                            }
                            cmaq.ExecuteNonQuery();
                            con.Close();
                        }
                        else if (Request.QueryString["f1d"] != null)
                        {
                            string     strc = "Update F1_F2_TaxDedctionTbl Set F1Doc='" + rst + "' where Id='" + Request.QueryString["f1d"] + "'";
                            SqlCommand cmaq = new SqlCommand(strc, con);
                            if (con.State.ToString() != "Open")
                            {
                                con.Open();
                            }
                            cmaq.ExecuteNonQuery();
                            con.Close();
                        }
                        else if (Request.QueryString["f2d"] != null)
                        {
                            string     strc = "Update F1_F2_TaxDedctionTbl Set F2Doc='" + rst + "' where Id='" + Request.QueryString["f2d"] + "'";
                            SqlCommand cmaq = new SqlCommand(strc, con);
                            if (con.State.ToString() != "Open")
                            {
                                con.Open();
                            }
                            cmaq.ExecuteNonQuery();
                            con.Close();
                        }

                        clear();
                    }
                    /////addede
                    int    ii        = 0;
                    string filepath1 = Server.MapPath("~//Account//" + Session["comid"] + "//UploadedDocuments//" + filename);
                    using (StreamReader st = new StreamReader(File.OpenRead(filepath1)))
                    {
                        Regex           regex = new Regex(@"/Type\s*/Page[^s]");
                        MatchCollection match = regex.Matches(st.ReadToEnd());
                        ii = match.Count;
                    }

                    int    length    = filename.Length;
                    string docnameIn = filename.Substring(0, length - 4);


                    for (int kk = 1; kk <= ii; kk++)
                    {
                        string scpf = docnameIn;
                        if (kk >= 1 && kk < 10)
                        {
                            scpf = scpf + "0000" + kk + ".jpg";
                        }
                        else if (kk >= 10 && kk < 100)
                        {
                            scpf = scpf + "000" + kk + ".jpg";
                        }
                        else if (kk >= 100)
                        {
                            scpf = scpf + "00" + kk + ".jpg";
                        }
                        clsEmployee.InserDocumentImageMaster(rst, scpf);
                    }


                    //}
                    //else
                    //{
                    //    lblmsg.Visible = true;
                    //  //  pnlmsg.Visible = true;
                    //    lblmsg.Text = "Your Storage accede more than limit ";
                    //}
                }
                else
                {
                    lblmsg.Visible = true;
                    //   pnlmsg.Visible = true;
                    lblmsg.Text = "Sorry, You are not permitted for greater record to Priceplan";
                }
            }
        }
        catch (Exception es)
        {
            lblmsg.Visible = true;
            // pnlmsg.Visible = true;
            lblmsg.Text = "error : " + es.Message;
        }
    }
    protected void imgbtnupdate_Click(object sender, EventArgs e)
    {
        if (ddlcopyormove.SelectedValue == "0")
        {
            foreach (GridViewRow grd in GridView2.Rows)
            {
                string         doc = "SELECT * FROM  DocumentMaster   where DocumentId='" + grd.Cells[0].Text + "'";
                SqlDataAdapter adp = new SqlDataAdapter(doc, con);
                DataTable      dt  = new DataTable();
                adp.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    bool insdata;
                    insdata = true;
                    Int32 rst = clsDocument.InsertDocumentMaster(Convert.ToInt32(ddldoctype.SelectedValue), 2, Convert.ToDateTime(dt.Rows[0]["DocumentUploadDate"]), Convert.ToString(dt.Rows[0]["DocumentName"]), Convert.ToString(dt.Rows[0]["DocumentTitle"]), Convert.ToString(dt.Rows[0]["Description"]), Convert.ToInt32(dt.Rows[0]["PartyId"]), Convert.ToString(dt.Rows[0]["DocumentRefNo"]), Convert.ToDecimal(dt.Rows[0]["DocumentAmount"]), Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(dt.Rows[0]["DocumentDate"]), Convert.ToString(ViewState["fileext"]), Convert.ToString(dt.Rows[0]["DocumentTypenmId"]), Convert.ToString(dt.Rows[0]["PartyDocrefno"]));
                    if (rst > 0)
                    {
                        //bool dcaprv = true;
                        //bool indc = clsDocument.insertDocumentProcessingnew(Convert.ToInt32(Session["EmployeeId"]), rst, dcaprv);
                        int accesslevel = 0;

                        string         strdesig = " select DesignationMaster.* from EmployeeMaster inner join DesignationMaster ON EmployeeMaster.DesignationMasterID = DesignationMaster.DesignationMasterID where EmployeeMaster.EmployeeMasterID='" + Convert.ToInt32(Session["EmployeeId"]) + "'  ";
                        SqlCommand     cmdeeed  = new SqlCommand(strdesig, con);
                        SqlDataAdapter adpeeed  = new SqlDataAdapter(cmdeeed);
                        DataTable      dteeed   = new DataTable();
                        adpeeed.Fill(dteeed);

                        if (dteeed.Rows.Count > 0)
                        {
                            ViewState["DesignationName"] = dteeed.Rows[0]["DesignationName"].ToString();
                        }
                        if (ViewState["DesignationName"].ToString() == "Manager")
                        {
                            accesslevel = 3;
                        }
                        else if (ViewState["DesignationName"].ToString() == "Supervisor")
                        {
                            accesslevel = 2;
                        }
                        else if (ViewState["DesignationName"].ToString() == "Office Clerk")
                        {
                            accesslevel = 1;
                        }
                        else
                        {
                            accesslevel = 0;
                        }

                        string         eeed     = " Select  * from  DocumentProcessing where  EmployeeId='" + Convert.ToInt32(Session["EmployeeId"]) + "' and DocumentId='" + rst + "'";
                        SqlCommand     cmdeeedc = new SqlCommand(eeed, con);
                        SqlDataAdapter adpeeedc = new SqlDataAdapter(cmdeeedc);
                        DataTable      dteeedc  = new DataTable();
                        adpeeedc.Fill(dteeedc);
                        if (dteeedc.Rows.Count <= 0)
                        {
                            string     str1 = " INSERT INTO DocumentProcessing  (DocumentId ,EmployeeId,DocAllocateDate,CID,StatusId,Levelofaccess) VALUES  ('" + rst + "' ,'" + Convert.ToInt32(Session["EmployeeId"]) + "','" + System.DateTime.Now.ToShortDateString() + "','" + Session["Comid"].ToString() + "','0','" + accesslevel + "') ";
                            SqlCommand cmd1 = new SqlCommand(str1, con);
                            con.Open();
                            insdata = Convert.ToBoolean(cmd1.ExecuteNonQuery());
                            con.Close();
                        }
                        bool fnws = clsDocument.UpdateDocumentDateDetail(rst, Convert.ToDateTime(dt.Rows[0]["DocumentDate"]));
                        int  rsts = clsDocument.InsertDocumentLog(rst, Convert.ToInt32(Session["EmployeeId"]), Convert.ToDateTime(System.DateTime.Now), false, false, true, false, false, false, false, false);


                        lblmsg.Text    = "Document copied successfully";
                        lblmsg.Visible = true;
                    }
                }
            }
        }
        else if (ddlcopyormove.SelectedValue == "1")
        {
            foreach (GridViewRow grd in GridView2.Rows)
            {
                string         doc = "SELECT * FROM  DocumentMaster   where DocumentId='" + grd.Cells[0].Text + "'";
                SqlDataAdapter adp = new SqlDataAdapter(doc, con);
                DataTable      dt  = new DataTable();
                adp.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    string     sr51   = "update DocumentMaster  set DocumentTypeId='" + ddldoctype.SelectedValue + "' where DocumentId='" + dt.Rows[0]["DocumentId"].ToString() + "'  ";
                    SqlCommand cmd801 = new SqlCommand(sr51, con);
                    if (con.State.ToString() != "Open")
                    {
                        con.Open();
                    }
                    cmd801.ExecuteNonQuery();
                    con.Close();


                    lblmsg.Text    = "Document moved successfully";
                    lblmsg.Visible = true;
                }
            }
        }
        else
        {
        }
    }