Beispiel #1
0
 /// <summary>
 /// ผลรวมข้อมูลทั้งหมด
 /// </summary>
 /// <param name="lsData"></param>
 /// <returns></returns>
 public static List <c_WastManage_Details> getTotal(List <c_WastManage_Details> lsData)
 {
     try
     {
         List <c_WastManage_Details> ls = new List <c_WastManage_Details>();
         using (SSLsEntities db = new SSLsEntities())
         {
             var sumPiece            = lsData.Sum(w => w.QTY);   // จำนวนชิ้น
             var sumList             = lsData.Count();           // รายการทั้งหมด
             var sumPrice            = lsData.Sum(w => w.Price); // ราคารวมทั้งหมด
             c_WastManage_Details wm = new c_WastManage_Details();
             wm.TotalPiece = sumPiece;
             wm.TotalList  = sumList;
             wm.TotalPrice = sumPrice;
             wm.ThaiBath   = Library.ThaiBaht(sumPrice.ToString());
             ls.Add(wm);
         }
         return(ls);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "แจ้งเตือนจากระบบ!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Beispiel #2
0
        /// <summary>
        /// รายการของเสีย
        /// </summary>
        /// <param name="code">รหัสใบของเสีย</param>
        /// <returns></returns>
        public static List <c_WastManage_Details> getList(string code)
        {
            try
            {
                List <c_WastManage_Details> ls      = new List <c_WastManage_Details>();
                List <c_WastManage_Details> lsGroup = new List <c_WastManage_Details>();
                using (SSLsEntities db = new SSLsEntities())
                {
                    var getHead = db.StoreFrontTransferWaste.FirstOrDefault(w => w.Enable == true && w.Code == code);

                    foreach (var sf in getHead.StoreFrontTransferWasteDtl.Where(w => w.Enable == true).ToList())
                    {
                        c_WastManage_Details wm = new c_WastManage_Details();
                        wm.ProductNo     = sf.ProductDetails.Code; // รหัสสินค้า
                        wm.ProductDetail = sf.ProductDetails.Products.ThaiName;
                        wm.ProductUnit   = sf.ProductDetails.ProductUnit.Name;
                        wm.QTY           = sf.Qty;         // ชิ้น
                        wm.Price         = sf.CostPerUnit; // ราคาต่อหน่วย
                        wm.Packsize      = sf.ProductDetails.PackSize;
                        // หมายเหตุ
                        wm.DescriptionList = sf.Description;
                        ls.Add(wm);
                    }
                    var groupData = ls.GroupBy(a => new { a.ProductNo })
                                    .Select(g => new { Key = g.Key, Count = g.Count() });
                    foreach (var dt in groupData)
                    {
                        c_WastManage_Details wm = new c_WastManage_Details();
                        wm.ProductNo     = ls.FirstOrDefault(w => w.ProductNo == dt.Key.ProductNo).ProductNo;
                        wm.ProductDetail = ls.FirstOrDefault(w => w.ProductNo == dt.Key.ProductNo).ProductDetail;
                        wm.ProductUnit   = ls.FirstOrDefault(w => w.ProductNo == dt.Key.ProductNo).ProductUnit;
                        wm.QTY           = ls.Where(w => w.ProductNo == dt.Key.ProductNo).Sum(w => w.QTY);   // ชิ้น
                        wm.Price         = ls.Where(w => w.ProductNo == dt.Key.ProductNo).Sum(w => w.Price); // ราคาต่อหน่วย
                        wm.Packsize      = ls.Where(w => w.ProductNo == dt.Key.ProductNo).Sum(w => w.Packsize);
                        // หมายเหตุ
                        wm.DescriptionList = ls.FirstOrDefault(w => w.ProductNo == dt.Key.ProductNo).DescriptionList;
                        lsGroup.Add(wm);
                    }
                }
                return(lsGroup);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "แจ้งเตือนจากระบบ!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Beispiel #3
0
        private void frmMainReport_Load(object sender, EventArgs e)
        {
            try
            {
                using (SSLsEntities db = new SSLsEntities())
                {
                    ReportParameter User       = new ReportParameter("User", Singleton.SingletonAuthen.Instance().Name);
                    ReportParameter Tel        = new ReportParameter("Tel", Singleton.SingletonAuthen.Instance().MyBranch.Tel);
                    ReportParameter Address    = new ReportParameter("Address", Singleton.SingletonAuthen.Instance().MyBranch.Address);
                    ReportParameter Fax        = new ReportParameter("Fax", Singleton.SingletonAuthen.Instance().MyBranch.Fax);
                    ReportParameter TaxNo      = new ReportParameter("TaxNo", Singleton.SingletonAuthen.Instance().MyBranch.TaxNo);
                    ReportParameter Email      = new ReportParameter("Email", Singleton.SingletonAuthen.Instance().MyBranch.Email);
                    ReportParameter BranchName = new ReportParameter("BranchName", Singleton.SingletonAuthen.Instance().MyBranch.Name + " " + Singleton.SingletonAuthen.Instance().MyBranch.BranchNo);
                    ReportParameter PrintDate  = new ReportParameter("PrintDate", Library.ConvertDateToThaiDate(DateTime.Now, true));

                    ReportParameter[] HeaderParams = { User, Tel, Fax, TaxNo, Email, BranchName, Address, PrintDate };

                    switch (this.TypeReport)
                    {
                    case MyConstant.TypeReport.ReportMemberChange:     /// รายงานสรุปการจ่ายปันผล-เฉลี่ยคืน

                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();

                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", this.dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_MemberReceiptReport.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.MemberChange2560:     /// ใบเสร็จปันผล

                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();

                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", receiptPaper));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_Dividend.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.GetGoodsFrontUse:     /// ใบเบิกใช้เอง
                        var headPaper = Repository.GetGoodsStorefrontUse.getHead(this.code);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", headPaper));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_GetGoodsUse.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.Adjust:
                        var dtAdjust = (Repository.Adjust.getData(this.code));
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dtAdjust));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_Adjust.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        break;

                    case MyConstant.TypeReport.MemberActive:     // สมาชิก คงอยู่ - ลาออก
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_MemberActive.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        break;

                    case MyConstant.TypeReport.InOutBalValueReport:     // ราคาทุน - ราคาขาย มูลค่า
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_ProductRawInOutDtl.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        break;

                    //this.TypeReport = MyConstant.TypeReport.InOutBalValueReport;
                    case MyConstant.TypeReport.CountProduct:
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_CountProduct.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        break;

                    case MyConstant.TypeReport.LeftInStockVat:     // ราคาทุน - ราคาขาย
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_LeftInStockVat.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        break;

                    case MyConstant.TypeReport.StockCard:     // รายงาน StockCard
                        /// ใบโอนของข้ามสาขา
                        //var head_fmo = Repository.TransferOut.getHead(this.code, brachDestination);
                        ReportParameter   user          = new ReportParameter("User", this.user);
                        ReportParameter   WhereDate     = new ReportParameter("WhereDate", this.whereDate);
                        ReportParameter   WhereProduct  = new ReportParameter("WhereProduct", this.whereProduct);
                        ReportParameter   WhereGroupP   = new ReportParameter("WhereGroupP", this.whereGroupP);
                        ReportParameter[] HeaderParams1 = { user, WhereDate, WhereProduct, WhereGroupP };


                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_StockCard.rdlc";
                        foreach (ReportParameter param in HeaderParams1)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.LeftInStock:     // รายงานสินค้าคงเหลือ
                        ///
                        //var head_cskdoc = Repository.CheckStockDoc.getData(this.ls);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_LeftInStock.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.InOutBalReport:     // รายงาน รับ-จ่าย-คงเหลือ

                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_ProductRawInOut.rdlc";
                        foreach (ReportParameter param in HeaderParams)
                        {
                            this.reportViewer1.LocalReport.SetParameters(param);
                        }
                        this.reportViewer1.RefreshReport();
                        break;

                    case MyConstant.TypeReport.CheckStockDoc:
                        ///
                        var head_cskdoc = Repository.CheckStockDoc.getData(this.ls);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", head_cskdoc));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_CheckStockDoc.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.CheckStock:
                        ///
                        var head_csk = Repository.CheckStock.getData(this.code);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", head_csk));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_CheckStock.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.RCVPO:
                        ///
                        var head_rcvpo = Repository.RCVPO.getData(this.code);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", head_rcvpo));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_RCVPO.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.GoodsReturnWms:
                        /// ใบส่งของคืนให้ผู้จัดจำหน่าย
                        var head_grw = Repository.GoodsReturnWms.getData(this.code);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", head_grw));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_GoodsReturnWms.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.CN:
                        // ใบรับคืน
                        var head_cn   = (Repository.CN.getHead(this.code));
                        var list_cn   = Repository.CN.getList(this.code);
                        var footer_cn = Repository.CN.getTotal(list_cn);

                        this.d1 = Library.ConvertToDataTable(head_cn);
                        this.d2 = Library.ConvertToDataTable(list_cn);
                        this.d3 = Library.ConvertToDataTable(footer_cn);

                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", d1));
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", d2));
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet3", d3));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_CN.rdlc";
                        this.reportViewer1.RefreshReport();
                        break;

                    case MyConstant.TypeReport.WastManage:
                        /// ใบของเสีย
                        var head_wm = Repository.WastManage.getHead(this.code);
                        //var list_wm = Repository.WastManage.getList(this.code);


                        var getList = db.StoreFrontTransferWasteDtl.Where(w => w.FKStoreFrontTransferWaste == code && w.Enable == true).ToList();
                        List <Repository.c_WastManage_Details> listData = new List <Repository.c_WastManage_Details>();
                        List <StoreFrontTransferWasteDtl>      result   = new List <StoreFrontTransferWasteDtl>();
                        result.AddRange(getList);
                        foreach (var item in getList)
                        {
                            // get 1 fkproductDtl
                            var data = result.Where(w => w.FKProductDetails == item.FKProductDetails).ToList();
                            if (data.Count() == 0)
                            {
                                continue;
                            }
                            Repository.c_WastManage_Details stack = new Repository.c_WastManage_Details();
                            stack.DescriptionList = "-";
                            var getProDtl = Singleton.SingletonProduct.Instance().ProductDetails.SingleOrDefault(w => w.Id == item.FKProductDetails);
                            stack.Packsize = getProDtl.PackSize;
                            // ทุนไม่รวมภาษี
                            stack.Price         = data.Sum(w => w.Qty) * getProDtl.CostOnly;
                            stack.ProductDetail = getProDtl.Products.ThaiName;
                            stack.ProductNo     = getProDtl.Code;
                            stack.ProductUnit   = getProDtl.ProductUnit.Name;
                            stack.QTY           = data.Sum(w => w.Qty);
                            stack.ThaiBath      = "";
                            listData.Add(stack);
                            foreach (var getcode in data)
                            {
                                result.Remove(getcode);
                            }
                        }
                        //GetValueByFKProduct(result);
                        var footer_wm = Repository.WastManage.getTotal(listData);
                        this.d1 = Library.ConvertToDataTable(head_wm);
                        this.d2 = Library.ConvertToDataTable(listData);
                        this.d3 = Library.ConvertToDataTable(footer_wm);

                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", d1));
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", d2));
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet3", d3));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_WastManage.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.TransferOut:
                        /// ใบโอนของข้ามสาขา
                        var head_fmo = Repository.TransferOut.getHead(this.code, brachDestination);
                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", head_fmo));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_TranferOut.rdlc";
                        this.reportViewer1.RefreshReport();
                        ///
                        break;

                    case MyConstant.TypeReport.OrderWarehouse:
                        var head      = (Repository.SaleOrderWarehouse.getHead(this.code));
                        var checkHead = db.SaleOrderWarehouse.SingleOrDefault(w => w.Code == this.code).Id;
                        var list      = Repository.SaleOrderWarehouse.getList(checkHead);
                        var footer    = Repository.SaleOrderWarehouse.getTotal(list);

                        this.d1 = Library.ConvertToDataTable(head);
                        this.d2 = Library.ConvertToDataTable(list);
                        this.d3 = Library.ConvertToDataTable(footer);

                        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", d1));
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", d2));
                        this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet3", d3));
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "Pos_Management_System.rw_SaleOrderWarehouse.rdlc";
                        this.reportViewer1.RefreshReport();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "แจ้งเตือนจากระบบ!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }