コード例 #1
0
ファイル: WarehouseDal.cs プロジェクト: SaintLoong/PFK
 public DataTable GetWarehouse()
 {
     using (PersistentManager pm = new PersistentManager())
     {
         WarehouseDao warehouseDao = new WarehouseDao();
         return warehouseDao.Find();
     }
 }
コード例 #2
0
ファイル: ReportDal.cs プロジェクト: SaintLoong/PFK
        public Dictionary<string, System.Drawing.Color> GenerateDetail(string beginID, string endID, DataTable reportTable)
        {
            Dictionary<string, System.Drawing.Color> result = new Dictionary<string, System.Drawing.Color>();

            using (PersistentManager pm = new PersistentManager())
            {
                ReportDao reportDao = new ReportDao();

                DataTable warehouseTable = new WarehouseDao().Find();
                foreach (DataRow warehouseRow in warehouseTable.Rows)
                {
                    string warehouseCode = warehouseRow["WAREHOUSECODE"].ToString();
                    string warehouseName = warehouseRow["WAREHOUSENAME"].ToString();

                    //��ȡ��Ʒ����ʼ�·ݵ��ڳ�����
                    DataTable productTable = reportDao.FindProduct(beginID, endID, warehouseCode);
                    DataTable billTable = reportDao.FindBills(beginID, endID, warehouseCode);

                    for (int i = 0; i < productTable.Rows.Count; i++)
                    {
                        DataRow productRow = productTable.Rows[i];

                        string productCode = productRow["PRODUCTCODE"].ToString();
                        string productName = productRow["PRODUCTNAME"].ToString();

                        result.Add(productName, i % 2 == 0 ?  System.Drawing.Color.FromArgb(192, 255, 192) : System.Drawing.Color.White);

                        double beginQuantity = Convert.ToDouble(productRow["BEGINQUANTITY"]);
                        double inTotal = 0, outTotal = 0;

                        DataRow reportRow = reportRow = reportTable.NewRow();
                        reportRow["WAREHOUSENAME"] = warehouseName;
                        reportRow["PRODUCTCODE"] = productCode;
                        reportRow["PRODUCTNAME"] = productName;
                        reportRow["BILLDATE"] = "�ڡ�����";
                        reportRow["ENDQUANTITY"] = beginQuantity;
                        reportTable.Rows.Add(reportRow);

                        DataRow[] billRows = billTable.Select(string.Format("PRODUCTCODE='{0}'", productCode), "PRODUCTCODE, BILLNO");
                        foreach (DataRow row in billRows)
                        {
                            string billType = row["BTYPE"].ToString();
                            double quantity = Convert.ToDouble(row["QUANTITY"]);

                            reportRow = reportTable.NewRow();
                            reportRow["WAREHOUSENAME"] = warehouseName;
                            reportRow["PRODUCTCODE"] = productCode;
                            reportRow["PRODUCTNAME"] = productName;
                            reportRow["BILLNO"] = row["BILLNO"];
                            reportRow["BILLDATE"] = row["BILLDATE"];

                            if (billType == "1" || billType == "7" || (billType == "6" && quantity > 0))
                            {
                                reportRow["INQUANTITY"] = quantity;
                                beginQuantity += quantity;
                                inTotal += quantity;

                                reportRow["ENDQUANTITY"] = beginQuantity;

                                reportTable.Rows.Add(reportRow);
                                System.Windows.Forms.Application.DoEvents();
                            }
                            else if (billType == "2" || (billType == "6" && quantity < 0))
                            {
                                reportRow["OUTQUANTITY"] = quantity;
                                beginQuantity -= Math.Abs(quantity);
                                outTotal += Math.Abs(quantity);

                                reportRow["ENDQUANTITY"] = beginQuantity;

                                reportTable.Rows.Add(reportRow);
                                System.Windows.Forms.Application.DoEvents();
                            }
                        }

                        reportRow = reportRow = reportTable.NewRow();

                        reportRow["WAREHOUSENAME"] = warehouseName;
                        reportRow["PRODUCTCODE"] = productCode;
                        reportRow["PRODUCTNAME"] = productName;
                        reportRow["BILLDATE"] = "�ϡ�����";
                        reportRow["INQUANTITY"] = inTotal;
                        reportRow["OUTQUANTITY"] = outTotal;
                        reportRow["ENDQUANTITY"] = beginQuantity;
                        reportTable.Rows.Add(reportRow);

                    }
                }
            }
            return result;
        }
コード例 #3
0
ファイル: ReportDal.cs プロジェクト: SaintLoong/PFK
        public void GenerateMaster(string beginID, string endID, DataTable reportTable)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                ReportDao reportDao = new ReportDao();

                DataTable warehouseTable = new WarehouseDao().Find();
                foreach (DataRow warehouseRow in warehouseTable.Rows)
                {
                    string warehouseCode = warehouseRow["WAREHOUSECODE"].ToString();
                    string warehouseName = warehouseRow["WAREHOUSENAME"].ToString();

                    //��ȡ��Ʒ����ʼ�·ݵ��ڳ�����
                    DataTable productTable = reportDao.FindProduct(beginID, endID, warehouseCode);

                    //���½��·ݵĻ�������
                    DataTable balancedTable = reportDao.FindBalancedTotal(beginID, endID, warehouseCode);

                    //δ�½��·ݵ��������
                    DataTable inTable = reportDao.FindUnBalancedTotal(beginID, warehouseCode, "1");

                    //δ�½��·ݵij�������
                    DataTable outTable = reportDao.FindUnBalancedTotal(beginID, warehouseCode, "2");

                    //δ�½��·ݵ���������
                    DataTable spillTable = reportDao.FindUnBalancedTotal(beginID, warehouseCode, "6");

                    DataTable returnTable = reportDao.FindUnBalancedTotal(beginID, warehouseCode, "7");

                    foreach (DataRow productRow in productTable.Rows)
                    {
                        string productCode = productRow["PRODUCTCODE"].ToString();
                        string productName = productRow["PRODUCTNAME"].ToString();
                        double beginQuantity = Convert.ToDouble(productRow["BEGINQUANTITY"]);

                        double inQuantity = 0, outQuantity = 0, quantity = 0;

                        DataRow[] balancedRows = balancedTable.Select(string.Format("PRODUCTCODE='{0}'", productCode));
                        if (balancedRows.Length != 0)
                        {
                            inQuantity = Convert.ToDouble(balancedRows[0]["INQUANTITY"]);
                            outQuantity = Convert.ToDouble(balancedRows[0]["OUTQUANTITY"]);
                            quantity = Convert.ToDouble(balancedRows[0]["QUANTITY"]);
                        }

                        object o = inTable.Compute("SUM(QUANTITY)", string.Format("PRODUCTCODE='{0}'", productCode));
                        if (o != DBNull.Value)
                            inQuantity += Convert.ToDouble(o);

                        o = outTable.Compute("SUM(QUANTITY)", string.Format("PRODUCTCODE='{0}'", productCode));
                        if (o != DBNull.Value)
                            outQuantity += Convert.ToDouble(o);

                        o = returnTable.Compute("SUM(QUANTITY)", string.Format("PRODUCTCODE='{0}'", productCode));
                        if (o != DBNull.Value)
                            outQuantity -= Convert.ToDouble(o);

                        o = spillTable.Compute("SUM(QUANTITY)", string.Format("PRODUCTCODE='{0}'", productCode));
                        if (o != DBNull.Value)
                            quantity += Convert.ToDouble(o);

                        DataRow reportRow = reportTable.NewRow();
                        reportRow["BEGINID"] = beginID;
                        reportRow["ENDID"] = endID;
                        reportRow["WAREHOUSENAME"] = warehouseName;
                        reportRow["PRODUCTNAME"] = productName;
                        reportRow["BEGINQUANTITY"] = beginQuantity;
                        reportRow["INQUANTITY"] = inQuantity;
                        reportRow["OUTQUANTITY"] = outQuantity;
                        reportRow["QUANTITY"] = quantity;
                        reportRow["ENDQUANTITY"] = beginQuantity + inQuantity - outQuantity + quantity;

                        reportTable.Rows.Add(reportRow);
                        System.Windows.Forms.Application.DoEvents();
                    }
                }
            }
        }