예제 #1
0
        private static void CalculateQty(DataRow DRCurrentMonth, DataTable DTPreviousMonth)
        {
            string TheColumns = "_DATE datetime,Restaurant_ID int,Kitchen_ID int,KitchenName varchar(50),Trantype varchar(50),ID varchar(50)";

            TheColumns += ",Item_ID varchar(50),ItemName varchar(50),Qty float,Current_Qty float,Cost float,CurrentCost float";
            Classes.CreateTable("TransActions", TheColumns);

            BETable = Classes.RetrieveStoredWithParamaeters("SPTransActions", "@StartDate,@EndDate", DRCurrentMonth["From"].ToString() + ',' + DRCurrentMonth["To"].ToString());

            where = "_DATE between '" + Convert.ToDateTime(DRCurrentMonth["From"].ToString()).ToString(Classes.sysDateTimeFormat) + "' AND '" + Convert.ToDateTime(DRCurrentMonth["To"].ToString()).ToString(Classes.sysDateTimeFormat) + "'";

            Classes.DeleteRows(where, "TransActions");

            for (int k = 0; k < BETable.Rows.Count; k++)
            {
                if (k == 0)
                {
                    GetPrevQty(k, DTPreviousMonth);
                }
                else if (BETable.Rows[k]["Trantype"].ToString() == "Adjactment")
                {
                    BETable.Rows[k]["Qty"] = (double.Parse(BETable.Rows[k]["Current_Qty"].ToString()) - double.Parse(BETable.Rows[k - 1]["Current_Qty"].ToString())).ToString();
                    string TempWhere = "Adjacment_ID = '" + BETable.Rows[k]["ID"].ToString() + "' And Item_ID = '" + BETable.Rows[k]["Item_ID"].ToString() + "'";
                    Classes.UpdateRow("Qty,Variance", BETable.Rows[k - 1]["Current_Qty"].ToString() + "," + BETable.Rows[k]["Qty"].ToString(), TempWhere, "Adjacment_Items");
                    Insert(k);
                }
                else if (BETable.Rows[k]["Item_ID"].ToString() == BETable.Rows[k - 1]["Item_ID"].ToString() && BETable.Rows[k]["KitchenName"].ToString() == BETable.Rows[k - 1]["KitchenName"].ToString())
                {
                    BETable.Rows[k]["Current_Qty"] = (double.Parse(BETable.Rows[k]["Current_Qty"].ToString()) + double.Parse(BETable.Rows[k - 1]["Current_Qty"].ToString())).ToString();
                    Insert(k);
                }
                else
                {
                    GetPrevQty(k, DTPreviousMonth);
                }
            }
        }