Example #1
0
    private void DisplayReportProductMovement()
    {
        ReportDocument            cryRpt           = new ReportDocument();
        List <RPT_STOCK_MOV_4127> rt_RPT_STOCK_MOV = new List <RPT_STOCK_MOV_4127>();

        rt_RPT_STOCK_MOV = Reports.RPT_STOCK_MOV_4127(string.Empty, CV_Code, CountStockDate_From, CountStockDate_To, ProductGroup, Size, string.Empty, string.Empty, string.Empty, string.Empty);
        foreach (var d in rt_RPT_STOCK_MOV)
        {
            d.pramCV_Code = CV_Code;
            if (d.pramCV_Code == "")
            {
                d.pramCV_Code = "ทั้งหมด";
            }

            if (CV_Code == "")
            {
                d.pramAgent_Name = "ทั้งหมด";
            }
            else
            {
                dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(CV_Code);
                d.pramAgent_Name = _agent.AgentName;
            }
            d.pramDate_From     = CountStockDate_From;
            d.pramDate_To       = CountStockDate_To;
            d.pramProduct_group = ProductGroup;
            if (d.pramProduct_group == "")
            {
                d.pramProduct_group = "เลือกทั้งหมด";
            }
            d.pramSize = Size;
            if (d.pramSize == "")
            {
                d.pramSize = "เลือกทั้งหมด";
            }
        }

        cryRpt.Load(Server.MapPath("~/Report/RT_ReportProductMovement.rpt"));
        cryRpt.SetDataSource(rt_RPT_STOCK_MOV);

        ReportViewer.ToolPanelView  = ToolPanelViewType.None;
        ReportViewer.HasCrystalLogo = false;
        //this.ReportViewer.PrintMode = PrintMode.ActiveX;
        ReportViewer.ReportSource = cryRpt;
        ReportViewer.RefreshReport();

        //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));

        //Response.ClearContent();
        //Response.ClearHeaders();
        //Response.ContentType = "application/pdf";
        //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)).ToArray());
        //Response.Flush();
        //Response.Close();
    }
Example #2
0
    private void DisplayReportDN_CN()
    {
        //ReportDocument cryRpt = new ReportDocument();

        List <RPT_DN_CN_41224> rt_RPT_DN_CN = new List <RPT_DN_CN_41224>();

        rt_RPT_DN_CN = Reports.RPT_DN_CN_41224(Region, AgentName, string.Empty, InvoiceDate, InvoiceDateTo, ddlType, CN_DN, Status, string.Empty);
        foreach (var d in rt_RPT_DN_CN)
        {
            d.paramRegion_Name = Request.QueryString["Region"];
            if (d.paramRegion_Name == "")
            {
                d.paramRegion_Name = "เลือกทั้งหมด";
            }
            if (AgentName != "")
            {
                _agent           = dbo_AgentDataClass.Select_Record(AgentName);
                d.pramAgent_Name = _agent.AgentName;
            }
            else
            {
                d.pramAgent_Name = "เลือกทั้งหมด";
            }
            d.pramDocNo = Request.QueryString["DebtID"];
            d.pramType  = Request.QueryString["ddlType"];
            if (d.pramType == "")
            {
                d.pramType = "เลือกทั้งหมด";
            }
            d.pramDebt_StartDate = Request.QueryString["InvoiceDate"];
            d.pramDebt_EndDate   = Request.QueryString["InvoiceDateTo"];
            d.pramStatus         = Request.QueryString["Status"];
            if (d.pramStatus == "")
            {
                d.pramStatus = "เลือกทั้งหมด";
            }
        }

        cryRpt.Load(Server.MapPath("~/Report/RT_ReportReduceDebt.rpt"));
        cryRpt.SetDataSource(rt_RPT_DN_CN);

        ReportViewer1.ToolPanelView  = ToolPanelViewType.None;
        ReportViewer1.HasCrystalLogo = false;
        ReportViewer1.ReportSource   = cryRpt;
        ReportViewer1.RefreshReport();

        //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
        //Response.ClearContent();
        //Response.ClearHeaders();
        //Response.ContentType = "application/pdf";
        //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
        //Response.Flush();
        //Response.Close();
    }
Example #3
0
    private void DisplayReportReduceDebt_CustomerAndSP()
    {
        ReportDocument cryRpt = new ReportDocument();

        connDB = new ConnectionManager();
        List <RPT_SP_DEBT_41221> rt_RPT_CUSTOMER_SP = new List <RPT_SP_DEBT_41221>();

        rt_RPT_CUSTOMER_SP = Reports.RPT_SP_DEBT_41221(Region, AgentName, SPName, DebtID, DebtName, DebtDate_From, DebtDate_To, Status, string.Empty, string.Empty);
        foreach (var d in rt_RPT_CUSTOMER_SP)
        {
            d.paramRegion_Name = Request.QueryString["Region"];
            if (d.paramRegion_Name == "")
            {
                d.paramRegion_Name = "เลือกทั้งหมด";
            }

            if (AgentName != "")
            {
                _agent           = dbo_AgentDataClass.Select_Record(AgentName);
                d.pramAgent_Name = _agent.AgentName;
            }
            else
            {
                d.pramAgent_Name = "เลือกทั้งหมด";
            }
            d.pramSP_Name        = Request.QueryString["SPName"];
            d.pramDebt_StartDate = Request.QueryString["DebtDate_From"];
            d.pramDebt_EndDate   = Request.QueryString["DebtDate_To"];
            d.pramStatus         = Request.QueryString["Status"];
            if (d.pramStatus == "")
            {
                d.pramStatus = "เลือกทั้งหมด";
            }
        }

        cryRpt.Load(Server.MapPath("~/Report/RT_ReportReduceDebt_CustomerAndSP.rpt"));
        cryRpt.SetDataSource(rt_RPT_CUSTOMER_SP);

        ReportViewer1.ToolPanelView  = ToolPanelViewType.None;
        ReportViewer1.HasCrystalLogo = false;
        ReportViewer1.ReportSource   = cryRpt;
        ReportViewer1.RefreshReport();

        //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
        //Response.ClearContent();
        //Response.ClearHeaders();
        //Response.ContentType = "application/pdf";
        //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
        //Response.Flush();
        //Response.Close();
    }
Example #4
0
    private void SetUpDrowDownList()
    {
        try
        {
            logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value;

            dbo_UserClass  user_class   = dbo_UserDataClass.Select_Record(User_ID);
            dbo_AgentClass clsdbo_Agent = dbo_AgentDataClass.Select_Record(user_class.CV_CODE);

            ViewState["CV_Code"] = clsdbo_Agent == null ? string.Empty : clsdbo_Agent.CV_Code;


            pnlForm.Visible = false;
            pnlGrid.Visible = true;

            List <dbo_UserClass> users = dbo_UserDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty
                                                                  , string.Empty, string.Empty, string.Empty, clsdbo_Agent == null ? string.Empty : clsdbo_Agent.CV_Code, null, string.Empty, string.Empty)
                                         .Where(f => f.Status == "Active")
                                         .Where(f => f.Position == "ซุปเปอร์ไวซ์เซอร์" || f.Position == "สาวส่งนม").ToList();


            users.Insert(0, new dbo_UserClass()
            {
                FullName = "==ระบุ==", User_ID = string.Empty
            });
            ddlSearchSP.DataSource = users;
            ddlSearchSP.DataBind();

            txtSum.Text = string.Empty;
            if (grdCommission.Rows.Count > 0)
            {
                List <dbo_ClearingClass> item = new List <dbo_ClearingClass>();
                grdCommission.DataSource = item;
                grdCommission.DataBind();
            }

            ddlStatus.SelectedIndex           = 0;
            txtClearing_No.Text               = string.Empty;
            txtRequisition_No.Text            = string.Empty;
            txtSearchClearing_Date_Begin.Text = DateTime.Now.ToShortDateString();
            txtSearchClearing_Date_End.Text   = DateTime.Now.ToShortDateString();
            txtRequistionStart.Text           = DateTime.Now.ToShortDateString();
            txtRequistionEnd.Text             = DateTime.Now.ToShortDateString();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string         User_ID      = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass  user_class   = dbo_UserDataClass.Select_Record(User_ID);
            dbo_AgentClass clsdbo_Agent = dbo_AgentDataClass.Select_Record(user_class.CV_CODE);

            if (user_class.User_Group_ID != "Agent")
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAM", "history.back();", true);
            }

            btnSearchSubmit_Click(sender, e);
        }
        txtStartDate.Text = DateTime.Now.ToShortDateString();
        txtEndDate.Text   = DateTime.Now.ToShortDateString();
    }
Example #6
0
    private void SetUpDrowDownList()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        try
        {
            //ddlAgentName
            List <dbo_AgentClass> agent = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
            dbo_AgentClass        a     = new dbo_AgentClass();
            a.Prefix_ID = "เลือกทั้งหมด";
            a.CV_Code   = string.Empty;
            agent.Insert(0, a);
            ddlAgentName.DataSource = agent;
            ddlAgentName.DataBind();
        }
        catch (Exception ex)
        {
            logger.Error(ex);
        }
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(Request.Cookies["User_ID"].Value);
            if (user_class.User_Group_ID != "Agent")
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAM", "history.back();", true);
            }
            else
            {
                dbo_AgentClass agent = dbo_AgentDataClass.Select_Record(user_class.CV_CODE);
                label_agent_name.Text = agent.AgentName;

                show_grid(user_class.CV_CODE);

                lblValue.Text = System.Convert.ToString(string.Format("{0:#,##0.00}", Grand_Total));
            }
        }
    }
Example #8
0
    protected void GenerateReport(string RPT, string PRM, string Region, string AgentName, string Month_From, string Month_To, string Year, string ProductGroup, string Size, string Unit, string SPName, string CV_Code, string ProductName, string Temp1)
    {
        try
        {
            ReportDocument cryRpt  = new ReportDocument();
            string         User_ID = Request.Cookies["User_ID"].Value;

            switch (RPT)
            {
            case "Requisition_No":


                List <RPT_Get_Requisition_No> rt_rqt = new List <RPT_Get_Requisition_No>();
                dbo_AgentClass clsdbo_Agent          = dbo_AgentDataClass.Select_Record(CV_Code);
                //dbo_RequisitionClearingClass rq_cl = dbo_RequisitionClearingDataClass.Search(string.Empty, string.Empty, string.Empty,null,null,null,null,string.Empty);
                List <dbo_RequisitionClearingClass> item = dbo_RequisitionClearingDataClass.Search(string.Empty, string.Empty, string.Empty, null, null, null, null, CV_Code);


                if (PRM == null)
                {
                    rt_rqt = Reports.RPT_Get_Requisition_No_Search(PRM, SPName.Substring(0, 11));



                    logger.Debug("SPName " + SPName);

                    if (SPName != "==ระบุ==")
                    {
                        // foreach (var d in rt_rqt)
                        // {
                        //     d.AgentName = AgentName;
                        //     d.sp_name = SPName.Substring(11);
                        //     d.User_SP = SPName.Substring(0, 10);
                        //     d.Invoice_Address = clsdbo_Agent.Adress_Agent;
                        //     d.Tax_ID = clsdbo_Agent.Tax_ID;
                        // }

                        logger.Debug("before sending report");
                        cryRpt.Load(Server.MapPath("~/Report_From/RT_Requisition_DOC001.rpt"));
                        cryRpt.SetDataSource(rt_rqt);
                    }
                    else
                    {
                        // Response.Redirect("กรุณาเลือกพนักงานขาย");
                        string script = "alert(\"กรุณาเลือกพนักงานขาย\");";
                        ScriptManager.RegisterStartupScript(this, GetType(),
                                                            "ServerControlScript", script, true);
                    }
                }
                else
                {
                    rt_rqt = Reports.RPT_Get_Requisition_No_Search(PRM, string.Empty);
                    int rqt_clm_tmp = rt_rqt.Where(f => f.clm_6 != 0 || f.clm_7 != 0 || f.clm_8 != 0 || f.clm_9 != 0 || f.clm_10 != 0).Count();

                    if (rqt_clm_tmp != 0)
                    {
                        cryRpt.Load(Server.MapPath("~/Report_From/RT_Requisition_DOC002.rpt"));
                        cryRpt.SetDataSource(rt_rqt);
                    }
                    else
                    {
                        cryRpt.Load(Server.MapPath("~/Report_From/RT_Requisition_DOC001.rpt"));
                        cryRpt.SetDataSource(rt_rqt);
                    }
                }

                break;

            case "PO_Number":
                List <RPT_Get_PO_Number> rt_po = new List <RPT_Get_PO_Number>();
                rt_po = Reports.RPT_Get_PO_Number_Search(PRM);
                cryRpt.Load(Server.MapPath("~/Report_From/RT_PO_DOC001.rpt"));
                cryRpt.SetDataSource(rt_po);
                break;

            case "Clearing_No":
                List <RPT_Get_Clearing_No> rt_clearing = new List <RPT_Get_Clearing_No>();
                rt_clearing = Reports.RPT_Get_Clearing_No(PRM);
                cryRpt.Load(Server.MapPath("~/Report_From/RT_Clearing_DOC002.rpt"));
                cryRpt.SetDataSource(rt_clearing);

                ReportDocument subRepDoc = cryRpt.Subreports["RPT_Subsidy.rpt"];
                List <RPT_Get_Clearing_No_Subsidy> rt_subsidy = new List <RPT_Get_Clearing_No_Subsidy>();
                rt_subsidy = Reports.RPT_Get_Clearing_No_Subsidy(PRM);
                subRepDoc.SetDataSource(rt_subsidy);

                ReportDocument subRepDoc1 = cryRpt.Subreports["RPT_Deduct.rpt"];
                List <RPT_Get_Clearing_No_Deduct> rt_deduct = new List <RPT_Get_Clearing_No_Deduct>();
                rt_deduct = Reports.RPT_Get_Clearing_No_Deduct(PRM);
                subRepDoc1.SetDataSource(rt_deduct);
                break;

            case "StockOnHandList":
                if (Temp1 == "Temp1")
                {
                    List <RPT_COUNT_STOCK_FORM_5> rt_StockOnHandList = new List <RPT_COUNT_STOCK_FORM_5>();
                    rt_StockOnHandList = Reports.RPT_COUNT_STOCK_FORM_5(null, CV_Code, null, null, null, null, null, null, null, null);
                    cryRpt.Load(Server.MapPath("~/Report_From/RT_CountStock.rpt"));
                    cryRpt.SetDataSource(rt_StockOnHandList);
                }
                else
                {
                    List <RPT_COUNT_STOCK_FORM_5> rt_StockOnHandList = new List <RPT_COUNT_STOCK_FORM_5>();
                    rt_StockOnHandList = Reports.RPT_COUNT_STOCK_FORM_5(null, null, PRM, null, null, null, null, null, null, null);
                    cryRpt.Load(Server.MapPath("~/Report_From/RT_CountStock.rpt"));
                    cryRpt.SetDataSource(rt_StockOnHandList);
                }


                break;

            case "CommissionReqList":
                // List<RPT_COUNT_STOCK_FORM_5> rt_StockOnHandList = new List<RPT_COUNT_STOCK_FORM_5>();
                List <RPT_RQ_CASH_FORM_4> rt_RQ_CASH_FORM_4 = new List <global::RPT_RQ_CASH_FORM_4>();
                rt_RQ_CASH_FORM_4 = Reports.RPT_RQ_CASH_FORM_4(null, null, PRM, null, null, null, null, null, null, User_ID);
                cryRpt.Load(Server.MapPath("~/Report_From/RT_CM_Requisition.rpt"));

                cryRpt.SetDataSource(rt_RQ_CASH_FORM_4);

                break;

            case "RPT_Order":
                //List<RPT_Get_Clearing_No> rt_clearing = new List<RPT_Get_Clearing_No>();
                //List<RPT_AnnualReport_4121> rt_RPT_Order = new List<RPT_AnnualReport_4121>();
                //rt_clearing = Reports.RPT_Get_Clearing_No(PRM);
                //rt_RPT_Order = Reports.RPT_AnnualReport_4121(Region,AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit);
                cryRpt.Load(Server.MapPath("~/Report/RT_ReportOrders.rpt"));
                //cryRpt.SetDataSource(rt_RPT_Order);
                break;

            case "ReportOrdersGroupProducts":
                //List<RPT_AnnualReport_4121> rt_RPT_Order = new List<RPT_AnnualReport_4121>();

                //rt_clearing = Reports.RPT_Get_Clearing_No(PRM);
                //rt_RPT_Order = Reports.RPT_AnnualReport_4121(Region, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit);

                cryRpt.Load(Server.MapPath("~/Report/RT_ReportOrdersGroupProducts.rpt"));
                //cryRpt.SetDataSource(rt_RPT_Order);
                break;

            case "ReportOrdersYearlyTarget":

                //List<RPT_AnnualReport_4121> rt_RPT_Order = new List<RPT_AnnualReport_4121>();

                //rt_clearing = Reports.RPT_Get_Clearing_No(PRM);
                //rt_RPT_Order = Reports.RPT_AnnualReport_4121(Region, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit);

                cryRpt.Load(Server.MapPath("~/Report/RT_ReportOrdersYearlyTarget.rpt"));
                //cryRpt.SetDataSource(rt_RPT_Order);
                break;

            case "Other_Requisition_No":

                List <RPT_Get_OtherRequisition_No> rt_other = new List <RPT_Get_OtherRequisition_No>();
                rt_other = Reports.RPT_Get_OtherRequisition_No(PRM);
                cryRpt.Load(Server.MapPath("~/Report_From/RT_OtherRequisition_DOC.rpt"));
                cryRpt.SetDataSource(rt_other);

                break;
            }

            // List<RT_PO_DOC> rt_doc = new List<RT_PO_DOC>();


            if (cryRpt != null)
            {
                BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));

                Response.ClearContent();
                Response.ClearHeaders();
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)).ToArray());
                Response.Flush();
                Response.Close();
            }
            else
            {
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
            //throw ex;
        }
    }
Example #9
0
    private void UpdateRecord()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        dbo_UserClass oclsdbo_User = new dbo_UserClass();

        // dbo_UserClass clsdbo_User = new dbo_UserClass();

        oclsdbo_User.User_ID = txtCP_User_ID.Text;
        oclsdbo_User         = dbo_UserDataClass.Select_Record(oclsdbo_User.User_ID);

        Validate("CPValidation");

        SetDataCP(oclsdbo_User);

        if (IsValid)
        {
            string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value;
            bool   success = dbo_UserDataClass.Update(oclsdbo_User, User_ID);

            if (success)
            {
                bool     flag      = false;
                String   strString = "0401,0402,0403,0404,0405";
                String[] myArr     = strString.Split(',');
                foreach (var d in myArr)
                {
                    if (d == oclsdbo_User.Item_Value_ID)
                    {
                        flag = true;
                    }
                }
                if (flag == true)
                {
                    //Show("gg");
                    List <dbo_AgentClass> agent    = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
                    List <dbo_AgentClass> _cv_code = new List <dbo_AgentClass>(agent.Where(f => f.DM_ID == oclsdbo_User.User_ID.Trim() || f.GM_ID == oclsdbo_User.User_ID.Trim() || f.SD_ID == oclsdbo_User.User_ID.Trim() || f.SM_ID == oclsdbo_User.User_ID.Trim() || f.APV_ID == oclsdbo_User.User_ID.Trim()).Select(f => f));

                    if (_cv_code.Count > 0)
                    {
                        foreach (var d in _cv_code)
                        {
                            dbo_AgentClass oclsdbo_Agent = new dbo_AgentClass();
                            // dbo_AgentClass clsdbo_Agent = new dbo_AgentClass();
                            oclsdbo_Agent.CV_Code = d.CV_Code;
                            oclsdbo_Agent         = dbo_AgentDataClass.Select_Record(oclsdbo_Agent.CV_Code);

                            if (d.APV_ID == oclsdbo_User.User_ID.Trim())
                            {
                                oclsdbo_Agent.APV_ID = string.Empty;
                                dbo_AgentDataClass.Update(oclsdbo_Agent, User_ID);
                                //Show("APV_ID");
                            }
                            else if (d.DM_ID == oclsdbo_User.User_ID.Trim())
                            {
                                oclsdbo_Agent.DM_ID = string.Empty;
                                dbo_AgentDataClass.Update(oclsdbo_Agent, User_ID);
                                //Show("DM_ID");
                            }
                            else if (d.GM_ID == oclsdbo_User.User_ID.Trim())
                            {
                                oclsdbo_Agent.GM_ID = string.Empty;
                                dbo_AgentDataClass.Update(oclsdbo_Agent, User_ID);
                                //Show("GM_ID");
                            }
                            else if (d.SD_ID == oclsdbo_User.User_ID.Trim())
                            {
                                oclsdbo_Agent.SD_ID = string.Empty;
                                dbo_AgentDataClass.Update(oclsdbo_Agent, User_ID);
                                //Show("SD_ID");
                            }
                            else if (d.SM_ID == oclsdbo_User.User_ID.Trim())
                            {
                                oclsdbo_Agent.SM_ID = string.Empty;
                                dbo_AgentDataClass.Update(oclsdbo_Agent, User_ID);
                                //Show("SM_ID");
                            }
                        }
                    }
                }



                Show("บันทึกสำเร็จ");
            }
            else
            {
                Show("error");
            }
        }
    }
Example #10
0
    private void DisplayReportExpenditure()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        try
        {
            List <RPT_EXPENSE_MONTHLY_41218> rt_RPT_EXPENSE_MONTHLY = new List <RPT_EXPENSE_MONTHLY_41218>();
            string                User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass         user_class = dbo_UserDataClass.Select_Record(User_ID);
            List <dbo_AgentClass> agent      = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
            if (user_class.User_Group_ID == "CP Meiji")
            {
                string region = user_class.Region;

                string[] regions = region.Split(',');

                List <dbo_AgentClass> cv_code_ = new List <dbo_AgentClass>();

                foreach (string in_region in regions)
                {
                    List <dbo_AgentClass> cv_code2 = new List <dbo_AgentClass>(agent.Where(f => f.Location_Region == in_region).Select(f => f));
                    foreach (dbo_AgentClass _cv in cv_code2)
                    {
                        //cv_code_.Add(_cv);
                        List <RPT_EXPENSE_MONTHLY_41218> _inrpt = Reports.RPT_EXPENSE_MONTHLY_41218(string.Empty, _cv.CV_Code, MonthGroup, MonthGroupTo, Year, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

                        foreach (RPT_EXPENSE_MONTHLY_41218 rpt in _inrpt)
                        {
                            rt_RPT_EXPENSE_MONTHLY.Add(rpt);
                        }
                    }
                }


                foreach (var d in rt_RPT_EXPENSE_MONTHLY)
                {
                    d.paramCV_Code = d.CV_Code;


                    dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(d.paramCV_Code);
                    d.paramCV_Name = _agent.AgentName;

                    //user_class = dbo_UserDataClass.Select_Record(d.paramCV_Code);
                    //d.paramCV_Name = user_class.AgentName;



                    d.paramYear       = Request.QueryString["Year"];
                    d.paramStartMonth = CV_Month(MonthGroup);
                    d.paramEndMonth   = CV_Month(MonthGroupTo);
                }
            }
            else
            {
                rt_RPT_EXPENSE_MONTHLY = Reports.RPT_EXPENSE_MONTHLY_41218(string.Empty, CV_CODE, MonthGroup, MonthGroupTo, Year, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

                foreach (var d in rt_RPT_EXPENSE_MONTHLY)
                {
                    d.paramCV_Code = CV_CODE;

                    dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(d.paramCV_Code);
                    d.paramCV_Name = _agent.AgentName;

                    d.paramYear       = Request.QueryString["Year"];
                    d.paramStartMonth = CV_Month(MonthGroup);
                    d.paramEndMonth   = CV_Month(MonthGroupTo);
                }
            }


            cryRpt.Load(Server.MapPath("~/Report/RT_ReportExpenditure.rpt"));
            cryRpt.SetDataSource(rt_RPT_EXPENSE_MONTHLY);

            ReportViewer1.ToolPanelView  = ToolPanelViewType.None;
            ReportViewer1.HasCrystalLogo = false;
            ReportViewer1.ReportSource   = cryRpt;
            ReportViewer1.RefreshReport();

            //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
            //Response.ClearContent();
            //Response.ClearHeaders();
            //Response.ContentType = "application/pdf";
            //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
            //Response.Flush();
            //Response.Close();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Example #11
0
    private void DisplayReportSummaryIncome()
    {
        try
        {
            List <RPT_SUMM_EXPENSE_41219> rt_RPT_EXPENSE = new List <RPT_SUMM_EXPENSE_41219>();


            string                User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass         user_class = dbo_UserDataClass.Select_Record(User_ID);
            List <dbo_AgentClass> agent      = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
            if (user_class.User_Group_ID == "CP Meiji")
            {
                string region = user_class.Region;

                string[] regions = region.Split(',');

                List <dbo_AgentClass> cv_code_ = new List <dbo_AgentClass>();

                foreach (string in_region in regions)
                {
                    List <dbo_AgentClass> cv_code2 = new List <dbo_AgentClass>(agent.Where(f => f.Location_Region == in_region).Select(f => f));
                    foreach (dbo_AgentClass _cv in cv_code2)
                    {
                        List <RPT_SUMM_EXPENSE_41219> _inrpt = Reports.RPT_SUMM_EXPENSE_41219(string.Empty, _cv.CV_Code, InvoiceDate, InvoiceDateTo, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

                        foreach (RPT_SUMM_EXPENSE_41219 rpt in _inrpt)
                        {
                            rt_RPT_EXPENSE.Add(rpt);
                        }
                    }
                }


                foreach (var d in rt_RPT_EXPENSE)
                {
                    d.paramCV_Code = d.CV_Code;

                    // dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(d.paramCV_Code);
                    dbo_AgentClass _agent = agent.FirstOrDefault(f => f.CV_Code == d.CV_Code);
                    if (_agent != null)
                    {
                        d.paramCV_Name = _agent.AgentName;
                    }

                    d.Temp0 = DateTime.Now.ToShortDateString();
                }
            }
            else
            {
                rt_RPT_EXPENSE = Reports.RPT_SUMM_EXPENSE_41219(string.Empty, CV_CODE, InvoiceDate, InvoiceDateTo, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

                foreach (var d in rt_RPT_EXPENSE)
                {
                    d.paramCV_Code = d.CV_Code;

                    // dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(d.paramCV_Code);
                    dbo_AgentClass _agent = agent.FirstOrDefault(f => f.CV_Code == d.CV_Code);

                    if (_agent != null)
                    {
                        d.paramCV_Name = _agent.AgentName;
                    }
                    d.Temp0 = DateTime.Now.ToShortDateString();
                }
            }



            /*
             * rt_RPT_EXPENSE = Reports.RPT_SUMM_EXPENSE_41219(string.Empty, CV_CODE, InvoiceDate, InvoiceDateTo, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
             *
             * foreach (var d in rt_RPT_EXPENSE)
             * {
             *  d.paramCV_Code = CV_CODE;
             *  user_class = dbo_UserDataClass.Select_Record(d.paramCV_Code);
             *  d.paramCV_Name = user_class.AgentName;
             * }
             */



            cryRpt.Load(Server.MapPath("~/Report/RT_ReportSummaryIncome.rpt"));
            cryRpt.SetDataSource(rt_RPT_EXPENSE);

            ReportViewer1.ToolPanelView  = ToolPanelViewType.None;
            ReportViewer1.HasCrystalLogo = false;
            ReportViewer1.ReportSource   = cryRpt;
            ReportViewer1.RefreshReport();

            //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
            //Response.ClearContent();
            //Response.ClearHeaders();
            //Response.ContentType = "application/pdf";
            //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
            //Response.Flush();
            //Response.Close();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Example #12
0
    protected void GenerateReport(string RPT, string PRM, string Region, string AgentName, string SPName, string JoinDate_From, string JoinDate_To, string WorkingAge_From, string WorkingAge_To, string ApprovalStatus, string Position,
                                  string RequisitionDate_From, string RequisitionDate_To, string ProductGroup, string Size, string Clearing_Date_From, string Clearing_Date_TO, string User_ID, string Lebel_SP)
    {
        try
        {
            ReportDocument cryRpt = new ReportDocument();

            switch (RPT)
            {
            case "ReportAllEmployee":
                ReportViewer1.ID = "รายงานจำนวนพนักงานทั้งหมดของศูนย์_" + datetime.Replace("/", string.Empty) + "_" + Time.Replace(":", string.Empty);
                List <RPT_SUMM_SP_BY_AGENT_41215> rt_RPT_Emp = new List <RPT_SUMM_SP_BY_AGENT_41215>();
                rt_RPT_Emp = Reports.RPT_SUMM_SP_BY_AGENT_41215(Region, AgentName, ApprovalStatus, Position, JoinDate_From, JoinDate_To
                                                                , WorkingAge_From, WorkingAge_To, SPName, string.Empty);

                if (rt_RPT_Emp.Count > 0)
                {
                    foreach (RPT_SUMM_SP_BY_AGENT_41215 r in rt_RPT_Emp)
                    {
                        r.paramRegion_Name = Request.QueryString["RegionName"];
                        r.paramCV_Name     = Request.QueryString["AgentFullName"];
                        r.paramSP_ID       = Request.QueryString["SPName"];
                        if ((Request.QueryString["SPFullName"] != null) && (Request.QueryString["SPName"] != null))
                        {
                            r.paramSP_Name = Request.QueryString["SPFullName"].Replace(Request.QueryString["SPName"], "");
                        }
                        r.paramStartDate_From = Request.QueryString["JoinDate_From"];
                        r.paramStartDate_To   = Request.QueryString["JoinDate_To"];
                        r.paramJoinDate_From  = Request.QueryString["WorkingAge_From"];
                        r.paramJoinDate_To    = Request.QueryString["WorkingAge_To"];

                        r.paramStatus   = Request.QueryString["ApprovalStatus"];
                        r.paramPosition = Request.QueryString["PositionFullName"];
                    }
                }

                cryRpt.Load(Server.MapPath("~/Report/RT_ReportAllEmployee.rpt"));
                cryRpt.SetDataSource(rt_RPT_Emp);
                break;

            case "ReportCommissions":
                ReportViewer1.ID = "รายงานค่าคอมมิชชั่น_" + datetime.Replace("/", string.Empty) + "_" + Time.Replace(":", string.Empty);
                List <RPT_SP_COMMISSION_41216> rt_RPT_Comm = new List <RPT_SP_COMMISSION_41216>();
                rt_RPT_Comm = Reports.RPT_SP_COMMISSION_41216(string.Empty, AgentName, SPName, RequisitionDate_From, RequisitionDate_To, ProductGroup, Size, Lebel_SP, string.Empty, string.Empty);
                foreach (var d in rt_RPT_Comm)
                {
                    if (AgentName == "")
                    {
                        d.paramCV_Code = "เลือกทั้งหมด";
                        d.paramCV_Name = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramCV_Code = AgentName;
                        //user_class = dbo_UserDataClass.Select_Record(AgentName);
                        //d.paramCV_Name = user_class.AgentName;
                        _agent         = dbo_AgentDataClass.Select_Record(AgentName);
                        d.paramCV_Name = _agent.AgentName;
                    }
                    d.paramStartDate = RequisitionDate_From;
                    d.paramEndDate   = RequisitionDate_To;
                    if (SPName == "")
                    {
                        d.paramSP_ID = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramSP_ID = SPName;
                    }
                    if (Lebel_SP == "")
                    {
                        d.paramSP_Name = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramSP_Name = Lebel_SP.Substring(11);
                    }

                    if (ProductGroup == "")
                    {
                        d.paramProduct_Group = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramProduct_Group = ProductGroup;
                    }

                    if (Size == "")
                    {
                        d.paramSize = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramSize = Size;
                    }
                }
                cryRpt.Load(Server.MapPath("~/Report/RT_ReportCommissions.rpt"));
                cryRpt.SetDataSource(rt_RPT_Comm);
                break;

            case "ReportWithdrawalCommissions":

                ReportViewer1.ID = "รายงานการเบิกค่าคอมมิชชั่น_" + datetime.Replace("/", string.Empty) + "_" + Time.Replace(":", string.Empty);
                List <RPT_REQUES_COMMISSION_41217> rt_RPT_RqComm = new List <RPT_REQUES_COMMISSION_41217>();
                rt_RPT_RqComm = Reports.RPT_REQUES_COMMISSION_41217(string.Empty, AgentName, SPName, Clearing_Date_From, Clearing_Date_TO, RequisitionDate_From, RequisitionDate_To, Lebel_SP, string.Empty, string.Empty);

                foreach (var d in rt_RPT_RqComm)
                {
                    if (AgentName == "")
                    {
                        d.paramCV_Code = "เลือกทั้งหมด";
                        d.paramCV_Name = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramCV_Code = AgentName;

                        //user_class = dbo_UserDataClass.Select_Record(AgentName);
                        //d.paramCV_Name = user_class.AgentName;
                        _agent         = dbo_AgentDataClass.Select_Record(AgentName);
                        d.paramCV_Name = _agent.AgentName;
                    }

                    d.paramCR_StartDate = Clearing_Date_From;
                    d.paramCR_EndDate   = Clearing_Date_TO;
                    d.paramRQ_StartDate = RequisitionDate_From;
                    d.paramRQ_EndDate   = RequisitionDate_To;

                    if (SPName == "")
                    {
                        d.paramSP_ID = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramSP_ID = SPName;
                    }
                    if (Lebel_SP == "")
                    {
                        d.paramSP_Name = "เลือกทั้งหมด";
                    }
                    else
                    {
                        d.paramSP_Name = Lebel_SP.Substring(11);
                    }
                }

                cryRpt.Load(Server.MapPath("~/Report/RT_ReportWithdrawalCommissions.rpt"));
                cryRpt.SetDataSource(rt_RPT_RqComm);
                break;
            }

            //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
            //Response.ClearContent();
            //Response.ClearHeaders();
            //Response.ContentType = "application/pdf";
            //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
            //Response.Flush();
            //Response.Close();

            ReportViewer1.ToolPanelView  = ToolPanelViewType.None;
            ReportViewer1.HasCrystalLogo = false;
            ReportViewer1.ReportSource   = cryRpt;
            ReportViewer1.RefreshReport();
        }
        catch (Exception ex)
        {
            // logger.Error(ex.Message);
        }
    }
Example #13
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Page.Validate("NewsValidation");

        if (IsValid)
        {
            DateTime startDate = Convert.ToDateTime(txtStart_Date.Text);
            DateTime endDate   = Convert.ToDateTime(txtEnd_Date.Text);
            DateTime today     = DateTime.Today;
            if (startDate < today)
            {
                System.Threading.Thread.Sleep(500);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
                Show("ไม่สามารถระบุวันที่เริ่มย้อนหลังได้");
            }
            else if (endDate < today)
            {
                System.Threading.Thread.Sleep(500);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
                Show("ไม่สามารถระบุวันที่สิ้นสุดย้อนหลังได้");
            }
            else if (startDate > endDate)
            {
                System.Threading.Thread.Sleep(500);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
                Show("ไม่สามารถระบุวันที่เริ่มมากกว่าวันที่สิ้นสุดได้");
            }
            else
            {
                string subject   = txtSubject.Text;
                string newsType  = ddlNewsType.SelectedValue.ToString();
                string contents  = txtContent.Text;
                string agentName = string.Empty;
                string cvCode    = string.Empty;

                if (!string.IsNullOrEmpty(ddlAgentName.SelectedValue.ToString()))
                {
                    agentName = ddlAgentName.SelectedItem.ToString();
                    cvCode    = ddlAgentName.SelectedValue.ToString();
                }

                string vdoHyperLink = txtVideo.Text;
                string userName     = User_ID;

                string fileName    = string.Empty;
                string contenttype = string.Empty;
                string imgName     = string.Empty;
                string imgType     = string.Empty;
                Byte[] fileBytes   = null;
                Byte[] imgBytes    = null;


                if (fulFileUpload.HasFile)
                {
                    string filePath = fulFileUpload.PostedFile.FileName;
                    fileName = Path.GetFileName(filePath);
                    string fileExt = Path.GetExtension(fileName);
                    contenttype = Common.Common.ContentType(fileExt);

                    Stream       fs = fulFileUpload.PostedFile.InputStream;
                    BinaryReader br = new BinaryReader(fs);
                    fileBytes = br.ReadBytes((Int32)fs.Length);
                }
                if (fulImgUpload.HasFile)
                {
                    string imgPath = fulImgUpload.PostedFile.FileName;
                    imgName = Path.GetFileName(imgPath);
                    string imgExt = Path.GetExtension(imgName);
                    imgType = Common.Common.ContentType(imgExt);

                    Stream       imgST = fulImgUpload.PostedFile.InputStream;
                    BinaryReader imgBR = new BinaryReader(imgST);
                    imgBytes = imgBR.ReadBytes((Int32)imgST.Length);
                }

                bool status = false;

                if (newsType == "ทั่วไป")
                {
                    string newsID = generateNewsID();
                    status = dbo_NewsDataClass.InsertNews(newsID, newsType, agentName, subject, contents, fileName, contenttype, fileBytes,
                                                          vdoHyperLink, startDate, endDate, imgName, imgType, imgBytes, userName, ddlAgentName.SelectedValue);
                }
                else
                {
                    List <ListItem> selected = new List <ListItem>();

                    foreach (ListItem item in ddlAgentName.Items)
                    {
                        string newsID = generateNewsID();
                        if (item.Selected)
                        {
                            dbo_AgentClass agent = dbo_AgentDataClass.Select_Record(item.Value);

                            selected.Add(item);
                            status = dbo_NewsDataClass.InsertNews(newsID, newsType, agent.AgentName, subject, contents, fileName, contenttype, fileBytes,
                                                                  vdoHyperLink, startDate, endDate, imgName, imgType, imgBytes, userName, item.Value);
                        }
                    }
                }

                if (status)
                {
                    System.Threading.Thread.Sleep(500);
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
                    // Show("บันทึกสำเร็จ!");

                    Session["CreateNews_Status"] = "true";
                    Session["SaveNew"]           = "SaveNew";
                    Response.Redirect("../Views/NewsList.aspx");

                    Session.Remove("fulFileUpload");
                    Session.Remove("fulImgUpload");
                }
            }
        }
        else
        {
            //            string script = @"swal({
            //                    title: ""กรุณากรอกข้อมูลที่จำเป็นให้ครบถ้วน"",
            //                    text: """",
            //                    type: ""error"",
            //                    confirmButtonText: ""ตกลง""
            //                });";
            //            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAM", script, true);
            System.Threading.Thread.Sleep(500);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('กรุณากรอกข้อมูลที่จำเป็นให้ครบถ้วน');", true);

            if (fulFileUpload.HasFile)
            {
                Session["fulFileUpload"] = fulFileUpload;
                lblfulFileUpload.Text    = fulFileUpload.FileName;
            }

            if (fulImgUpload.HasFile)
            {
                Session["fulImgUpload"] = fulImgUpload;
                lblfulImgUpload.Text    = fulImgUpload.FileName;
            }
        }
    }
Example #14
0
    protected void GenerateReport(string RPT, string PRM, string Region, string AgentName, string SPName, string InvoiceDate, string InvoiceDateTo, string ProductGroup, string Size, string CountStockDate_From, string CountStockDate_To, string productname, string RequisitionName, string Reason, string PRM1, string CV_Code)
    {
        try
        {
            ReportDocument cryRpt = new ReportDocument();

            switch (RPT)
            {
            case "ReportSummaryPickingSPList":

                List <RPT_SUMM_RQ_SP_4126> rt_RPT_SUMM_RQ_SP = new List <RPT_SUMM_RQ_SP_4126>();
                //rt_RPT_SUMM_RQ_SP = Reports.RPT_SUMM_RQ_SP_4126(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,string.Empty);
                rt_RPT_SUMM_RQ_SP = Reports.RPT_SUMM_RQ_SP_4126(Region, AgentName, SPName, InvoiceDate, InvoiceDateTo, ProductGroup, Size, string.Empty, string.Empty, string.Empty);
                cryRpt.Load(Server.MapPath("~/Report/RT_ReportSummaryPickingSPList.rpt"));
                cryRpt.SetDataSource(rt_RPT_SUMM_RQ_SP);
                break;

            case "ReportProductMovement":

                List <RPT_STOCK_MOV_4127> rt_RPT_STOCK_MOV = new List <RPT_STOCK_MOV_4127>();

                // rt_RPT_STOCK_MOV = Reports.RPT_STOCK_MOV_4127(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
                rt_RPT_STOCK_MOV = Reports.RPT_STOCK_MOV_4127(string.Empty, CV_Code, CountStockDate_From, CountStockDate_To, ProductGroup, Size, string.Empty, string.Empty, string.Empty, string.Empty);
                foreach (var d in rt_RPT_STOCK_MOV)
                {
                    d.pramCV_Code = CV_Code;
                    if (d.pramCV_Code == "")
                    {
                        d.pramCV_Code = "ทั้งหมด";
                    }

                    if (CV_Code == "")
                    {
                        d.pramAgent_Name = "ทั้งหมด";
                    }
                    else
                    {
                        dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(CV_Code);
                        d.pramAgent_Name = _agent.AgentName;
                    }
                    d.pramDate_From     = CountStockDate_From;
                    d.pramDate_To       = CountStockDate_To;
                    d.pramProduct_group = ProductGroup;
                    if (d.pramProduct_group == "")
                    {
                        d.pramProduct_group = "เลือกทั้งหมด";
                    }
                    d.pramSize = Size;
                    if (d.pramSize == "")
                    {
                        d.pramSize = "เลือกทั้งหมด";
                    }
                }

                cryRpt.Load(Server.MapPath("~/Report/RT_ReportProductMovement.rpt"));
                cryRpt.SetDataSource(rt_RPT_STOCK_MOV);
                break;

            case "ReportProductAdjustStock":

                List <RPT_ADJ_STOCK__4128> rt_RPT_ADJ_STOCK = new List <RPT_ADJ_STOCK__4128>();

                //rt_RPT_ADJ_STOCK = Reports.RPT_ADJ_STOCK__4128(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
                rt_RPT_ADJ_STOCK = Reports.RPT_ADJ_STOCK__4128(string.Empty, CV_Code, CountStockDate_From, CountStockDate_To, ProductGroup, Size, string.Empty, string.Empty, string.Empty, string.Empty);
                cryRpt.Load(Server.MapPath("~/Report/RT_ReportProductAdjustStock.rpt"));
                cryRpt.SetDataSource(rt_RPT_ADJ_STOCK);
                break;

            case "ReportSummaryPickingOtherProduct":
                List <RPT_SUMM_RQ_OTHER__4129> rt_RPT_SUMM_RQ_OTHER = new List <RPT_SUMM_RQ_OTHER__4129>();
                //rt_RPT_SUMM_RQ_OTHER = Reports.RPT_SUMM_RQ_OTHER__4129(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
                rt_RPT_SUMM_RQ_OTHER = Reports.RPT_SUMM_RQ_OTHER__4129(string.Empty, CV_Code, CountStockDate_From, CountStockDate_To, productname, RequisitionName, Reason, string.Empty, string.Empty, string.Empty);
                cryRpt.Load(Server.MapPath("~/Report/RT_ReportSummaryPickingOtherProduct.rpt"));
                cryRpt.SetDataSource(rt_RPT_SUMM_RQ_OTHER);
                break;

            case "Clearing_No":

                List <RPT_CLR_SALE_SUM_FORM_1_3> RPT_FORM_1_3 = new List <RPT_CLR_SALE_SUM_FORM_1_3>();
                RPT_FORM_1_3 = Reports.RPT_CLR_SALE_SUM_FORM_1_3(PRM);

                cryRpt.Load(Server.MapPath("~/ViewsMockup/RT_SalesSummaryByProduct.rpt"));
                cryRpt.SetDataSource(RPT_FORM_1_3);
                break;

            case "Requisition_No":

                List <RPT_Get_Requisition_No> rt_rqt = new List <RPT_Get_Requisition_No>();
                rt_rqt = Reports.RPT_Get_Requisition_No_Search(PRM, string.Empty);
                int rqt_clm_tmp = rt_rqt.Where(f => f.clm_6 != 0 || f.clm_7 != 0 || f.clm_8 != 0 || f.clm_9 != 0 || f.clm_10 != 0).Count();

                if (rqt_clm_tmp != 0)
                {
                    cryRpt.Load(Server.MapPath("~/ViewsMockup/RT_Requisition_DOC002.rpt"));
                    cryRpt.SetDataSource(rt_rqt);
                }
                else
                {
                    cryRpt.Load(Server.MapPath("~/ViewsMockup/RT_Requisition_DOC001.rpt"));
                    cryRpt.SetDataSource(rt_rqt);
                }

                break;

            //Requisition_No1
            case "Requisition_No1":

                //List<RPT_Get_Requisition_No> rt_rqt = new List<RPT_Get_Requisition_No>();
                rt_rqt = Reports.RPT_Get_Requisition_No_Search(PRM1, string.Empty);
                int rqt_clm_tmp1 = rt_rqt.Where(f => f.clm_6 != 0 || f.clm_7 != 0 || f.clm_8 != 0 || f.clm_9 != 0 || f.clm_10 != 0).Count();

                if (rqt_clm_tmp1 != 0)
                {
                    cryRpt.Load(Server.MapPath("~/ViewsMockup/RT_Requisition_DOC002.rpt"));
                    cryRpt.SetDataSource(rt_rqt);
                }
                else
                {
                    cryRpt.Load(Server.MapPath("~/ViewsMockup/RT_Requisition_DOC001.rpt"));
                    cryRpt.SetDataSource(rt_rqt);
                }

                break;
            }

            BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Example #15
0
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        try
        {
            System.Threading.Thread.Sleep(500);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);


            List <RPT_SUMM_EXPENSE_41219> rt_RPT_EXPENSE = new List <RPT_SUMM_EXPENSE_41219>();
            string                User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass         user_class = dbo_UserDataClass.Select_Record(User_ID);
            List <dbo_AgentClass> agent      = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
            if (user_class.User_Group_ID == "CP Meiji")
            {
                string region = user_class.Region;

                string[] regions = region.Split(',');

                List <dbo_AgentClass> cv_code_ = new List <dbo_AgentClass>();

                foreach (string in_region in regions)
                {
                    List <dbo_AgentClass> cv_code2 = new List <dbo_AgentClass>(agent.Where(f => f.Location_Region == in_region).Select(f => f));
                    foreach (dbo_AgentClass _cv in cv_code2)
                    {
                        List <RPT_SUMM_EXPENSE_41219> _inrpt = Reports.RPT_SUMM_EXPENSE_41219(string.Empty, user_class.CV_CODE, InvoiceDate.Text, InvoiceDateTo.Text, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

                        foreach (RPT_SUMM_EXPENSE_41219 rpt in _inrpt)
                        {
                            rt_RPT_EXPENSE.Add(rpt);
                        }
                    }
                }


                foreach (var d in rt_RPT_EXPENSE)
                {
                    d.paramCV_Code = d.CV_Code;

                    // dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(d.paramCV_Code);
                    dbo_AgentClass _agent = agent.FirstOrDefault(f => f.CV_Code == d.CV_Code);
                    if (_agent != null)
                    {
                        d.paramCV_Name = _agent.AgentName;
                    }
                }
            }
            else
            {
                rt_RPT_EXPENSE = Reports.RPT_SUMM_EXPENSE_41219(string.Empty, user_class.CV_CODE, InvoiceDate.Text, InvoiceDateTo.Text, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

                foreach (var d in rt_RPT_EXPENSE)
                {
                    d.paramCV_Code = d.CV_Code;

                    // dbo_AgentClass _agent = dbo_AgentDataClass.Select_Record(d.paramCV_Code);
                    dbo_AgentClass _agent = agent.FirstOrDefault(f => f.CV_Code == d.CV_Code);

                    if (_agent != null)
                    {
                        d.paramCV_Name = _agent.AgentName;
                    }
                }
            }


            if (rt_RPT_EXPENSE.Count > 0)
            {
                //string User_ID = Request.Cookies["User_ID"].Value;
                string url = "../Report/ReportViewer_01.aspx?RPT=ReportSummaryIncome&InvoiceDate=" + InvoiceDate.Text
                             + "&InvoiceDateTo=" + InvoiceDateTo.Text
                             + "&CV_CODE=" + user_class.CV_CODE;

                string s = "window.open('" + url + "', 'popup_window', 'width=1024,height=768,left=100,top=100,resizable=yes');";

                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAM", s, true);
            }
            else
            {
                Messages.Show("ไม่พบข้อมูล กรุณาเลือกเงื่อนไขอีกครั้ง", this.Page);
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Example #16
0
    private void DisplayReportOrders()
    {
        ReportDocument cryRpt = new ReportDocument();
        List <RPT_AnnualReport_4121> rt_RPT_Order = new List <RPT_AnnualReport_4121>();

        //rt_RPT_Order = Reports.RPT_AnnualReport_4121(Region, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit, string.Empty);

        user_class = dbo_UserDataClass.Select_Record(User_ID);
        List <dbo_AgentClass> agent = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);

        if (user_class.User_Group_ID == "CP Meiji")
        {
            string   region  = user_class.Region;
            string[] regions = region.Split(',');

            List <dbo_AgentClass> cv_code2 = new List <dbo_AgentClass>(agent.Where(f => regions.Contains(f.Location_Region)).Select(f => f));
            List <dbo_AgentClass> cv_code1 = new List <dbo_AgentClass>(agent.Where(f => f.DM_ID == User_ID || f.GM_ID == User_ID.Trim() || f.SD_ID == User_ID.Trim() || f.SM_ID == User_ID.Trim() || f.APV_ID == User_ID.Trim()).Select(f => f));

            if (cv_code1.Count > 0)
            {
                if (AgentName == string.Empty)
                {
                    foreach (dbo_AgentClass _cv in cv_code1)
                    {
                        List <RPT_AnnualReport_4121> _inrpt = Reports.RPT_AnnualReport_4121(Region, _cv.CV_Code, Month_From, Month_To, Year, ProductGroup, Size, Unit, string.Empty);

                        foreach (RPT_AnnualReport_4121 rpt in _inrpt)
                        {
                            rt_RPT_Order.Add(rpt);
                        }
                    }
                }
                else
                {
                    foreach (dbo_AgentClass _cv in cv_code1)
                    {
                        List <RPT_AnnualReport_4121> _inrpt = Reports.RPT_AnnualReport_4121(Region, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit, string.Empty);

                        foreach (RPT_AnnualReport_4121 rpt in _inrpt)
                        {
                            rt_RPT_Order.Add(rpt);
                        }
                    }
                }
            }
            else
            {
                if (Region == string.Empty)
                {
                    foreach (dbo_AgentClass _cv in cv_code2)
                    {
                        List <RPT_AnnualReport_4121> _inrpt = Reports.RPT_AnnualReport_4121(_cv.Location_ID, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit, string.Empty);

                        foreach (RPT_AnnualReport_4121 rpt in _inrpt)
                        {
                            rt_RPT_Order.Add(rpt);
                        }
                    }
                }
                else
                {
                    foreach (dbo_AgentClass _cv in cv_code2)
                    {
                        List <RPT_AnnualReport_4121> _inrpt = Reports.RPT_AnnualReport_4121(Region, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit, string.Empty);

                        foreach (RPT_AnnualReport_4121 rpt in _inrpt)
                        {
                            rt_RPT_Order.Add(rpt);
                        }
                    }
                }
            }
        }
        else
        {
            rt_RPT_Order = Reports.RPT_AnnualReport_4121(Region, AgentName, Month_From, Month_To, Year, ProductGroup, Size, Unit, string.Empty);
        }

        foreach (var d in rt_RPT_Order)
        {
            if (Region == "")
            {
                d.paramRegion_Name = "เลือกทั้งหมด";
            }
            else
            {
                d.paramRegion_Name = CV_RegionName(Region);
            }
            if (AgentName != "")
            {
                //user_class = dbo_UserDataClass.Select_Record(AgentName);
                //d.pramAgent_Name = user_class.AgentName;
                _agent           = dbo_AgentDataClass.Select_Record(AgentName);
                d.pramAgent_Name = _agent.AgentName;
            }
            else
            {
                d.pramAgent_Name = "เลือกทั้งหมด";
            }
            d.pramMonth_From = CV_Month(Month_From);
            d.pramMonth_To   = CV_Month(Month_To);
            d.pramYear       = Year;

            if (ProductGroup == "")
            {
                d.pramProduct_Group = "เลือกทั้งหมด";
            }
            else
            {
                d.pramProduct_Group = ProductGroup;
            }

            if (Size == "")
            {
                d.pramSize = "เลือกทั้งหมด";
            }
            else
            {
                d.pramSize = Size;
            }

            if (Unit == "จำนวนเงิน")
            {
                d.pramUnitType = "บาท";
            }
            else if (Unit == "จำนวนหน่วย")
            {
                d.pramUnitType = "หน่วย";
            }
        }

        cryRpt.Load(Server.MapPath("~/Report/RT_ReportOrders.rpt"));
        cryRpt.SetDataSource(rt_RPT_Order);

        ReportViewer.ToolPanelView  = ToolPanelViewType.None;
        ReportViewer.HasCrystalLogo = false;
        //this.ReportViewer.PrintMode = PrintMode.ActiveX;
        ReportViewer.ReportSource = cryRpt;
        ReportViewer.RefreshReport();

        //BinaryReader stream = new BinaryReader(cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));

        //Response.ClearContent();
        //Response.ClearHeaders();
        //Response.ContentType = "application/pdf";
        //Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)).ToArray());
        //Response.Flush();
        //Response.Close();
    }