Example #1
0
        /// <summary>
        /// 根据一批入库记录作为初始化的库存
        /// </summary>
        /// <param name="PaperInData"></param>
        /// <returns></returns>
        public static DataTable InitStoreList(DataTable PaperInData, int year, int month)
        {
            if (PaperInData != null)
            {
                List <Store_month> StoreList = new List <Store_month>();
                List <Paper_Store> PaperList = Paper_Store.GetAllPaperList();
                //List<Paper_Store> NeedSavePaperList = new List<Paper_Store>();
                List <Paper_In> DataList = DataSource.ORMHelper.TbToModelList <Paper_In>(PaperInData);

                for (int i = 0; i < PaperList.Count; i++)
                {
                    Store_month st = new Store_month();
                    st.PaperId   = PaperList[i].PaperId;
                    st.PaperName = PaperList[i].PaperName;
                    int index = -1;
                    for (int j = 0; j < DataList.Count; j++)
                    {
                        if (DataList[j].PaperId == PaperList[i].PaperId)
                        {
                            index         = j;
                            st.LastNum   += DataList[index].Num;
                            st.LastMoney += DataList[index].Money;
                        }
                    }
                    st.Year         = year;
                    st.Month        = month;
                    st.OrderNo      = year * 100 + month;
                    st.CalTime      = DateTime.Now;
                    st.CurrentMoney = st.LastMoney;
                    st.CurrentNum   = st.LastNum;
                    if (st.CurrentNum != 0)
                    {
                        st.CurrentPrice = Math.Abs(Math.Round(st.LastMoney / st.LastNum, 2));
                    }
                    else
                    {
                        st.CurrentPrice = 0;
                    }
                    //清除原来所有的当前库存;
                    //if (PaperList[i].Num != 0 || PaperList[i].TaxiMoney != 0 || PaperList[i].TaxiPrice != 0)
                    //{
                    //    PaperList[i].Num = 0;
                    //    PaperList[i].TaxiMoney = 0;
                    //    PaperList[i].TaxiPrice = 0;
                    //    NeedSavePaperList.Add(PaperList[i]);
                    //}
                    StoreList.Add(st);
                }
                return(DataSource.ORMHelper.ModelListToTb <Store_month>(StoreList));
            }
            return(null);
        }
Example #2
0
 public static int Delete(Paper_Store ps)
 {
     NeedRead = true;
     return(DataSource.ORMHelper.DeleteModelById <Paper_Store>(ps));
 }
Example #3
0
        public static int InserData(Paper_Store pi)
        {
            NeedRead = true;

            return(DataSource.ORMHelper.InsertModel <Paper_Store>(pi));
        }
Example #4
0
 public static int Update(Paper_Store paper)
 {
     NeedRead = true;
     return(DataSource.ORMHelper.UpdateModelById <Paper_Store>(paper));
 }
Example #5
0
        public static List <Paper_Out> TransMaterListToOutList(List <P_Order> allorder)
        {
            List <Paper_Out>   Plist  = new List <Paper_Out>();
            List <Paper_Store> Papers = Paper_Store.GetAllPaperList();

            List <P_MaterialList2> M2List;
            string orderlist = "";

            foreach (P_Order order in allorder)
            {
                string oderno = order.OrderOn;
                oderno     = oderno.Replace("O", "PUB");
                oderno     = "'" + oderno + "',";
                orderlist += oderno;
                //List<P_MaterialList2> mlist = P_MaterialList2.GetDataList("OrderOn='" + oderno + "'");
            }
            orderlist = orderlist.Remove(orderlist.Length - 1, 1);
            M2List    = P_MaterialList2.GetDataList("OrderOn in (" + orderlist + ") and Status=0");
            foreach (P_Order order in allorder)
            {
                string oderno = order.OrderOn;
                oderno = oderno.Replace("O", "PUB");
                List <P_MaterialList2> mlist = new List <P_MaterialList2>();
                for (int j = 0; j < M2List.Count; j++)
                {
                    if (M2List[j].OrderOn == oderno)
                    {
                        mlist.Add(M2List[j]);
                    }
                }
                // List<P_MaterialList2> mlist = P_MaterialList2.GetDataList("OrderOn='" + oderno + "'");
                if (mlist != null)
                {
                    for (int i = 0; i < mlist.Count; i++)
                    {
                        Paper_Out po = new Paper_Out();
                        po.OrderNo  = order.OrderOn;
                        po.OutTime  = order.OrderTime;
                        po.Remark   = order.Receiver;
                        po.RealTime = DateTime.Now;
                        po.b1       = order.b2;

                        po.Num     = mlist[i].Num + mlist[i].ExtendNum;
                        po.PaperId = mlist[i].b1;
                        Paper_Store ps = null;
                        foreach (Paper_Store p1 in Papers)
                        {
                            if (p1.PaperId == po.PaperId)
                            {
                                ps = p1;
                                break;
                            }
                        }
                        if (ps != null)
                        {
                            po.PaperName  = mlist[i].b2;
                            po.Price      = ps.TaxiPrice;
                            po.Money      = po.Num * po.Price;
                            po.Money      = Math.Round(po.Money, 2);
                            po.SourceCode = OutStoreCode.生产出库.ToString();
                            po.Active     = true;
                            po.b2         = mlist[i].Id;
                            Plist.Add(po);
                        }
                    }
                }
            }
            if (Plist.Count > 0)
            {
                return(Plist);
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        public static DataTable MakeNewStore(int year, int month)
        {
            List <Store_month> StoreList = new List <Store_month>();
            List <Paper_Store> PaperList = Paper_Store.GetAllPaperList();

            List <Paper_In>  InList  = Paper_In.GetYearMonthList(year, month);
            List <Paper_Out> OutList = Paper_Out.GetYearMonthList(year, month);

            List <Store_month> Lastlist;

            Store_month total = new Store_month();

            if (month == 1)
            {
                Lastlist = GetMonthStoreList(year - 1, 12);
            }
            else
            {
                Lastlist = GetMonthStoreList(year, month - 1);
            }
            for (int i = 0; i < PaperList.Count; i++)
            {
                Store_month st = new Store_month();
                st.PaperId   = PaperList[i].PaperId;
                st.PaperName = PaperList[i].PaperName;
                int index = -1;
                if (InList != null)
                {
                    for (int j = 0; j < InList.Count; j++)
                    {
                        if (InList[j].PaperId == PaperList[i].PaperId)
                        {
                            index       = j;
                            st.InNum   += InList[index].Num;
                            st.InMoney += InList[index].Money;
                        }
                    }
                }
                if (OutList != null)
                {
                    for (int j = 0; j < OutList.Count; j++)
                    {
                        if (OutList[j].PaperId == PaperList[i].PaperId)
                        {
                            index        = j;
                            st.OutNum   += OutList[index].Num;
                            st.OutMoney += OutList[index].Money;
                        }
                    }
                }
                if (Lastlist != null)
                {
                    for (int j = 0; j < Lastlist.Count; j++)
                    {
                        if (Lastlist[j].PaperId == PaperList[i].PaperId)
                        {
                            index        = j;
                            st.LastNum   = Lastlist[index].CurrentNum;
                            st.LastMoney = Lastlist[index].CurrentMoney;
                        }
                    }
                }
                st.Year         = year;
                st.Month        = month;
                st.OrderNo      = year * 100 + month;
                st.CalTime      = DateTime.Now;
                st.CurrentNum   = PaperList[i].Num;
                st.CurrentPrice = PaperList[i].TaxiPrice;
                st.CurrentMoney = PaperList[i].TaxiMoney;
                StoreList.Add(st);
                total.LastNum      += st.LastNum;
                total.LastMoney    += st.LastMoney;
                total.InNum        += st.InNum;
                total.InMoney      += st.InMoney;
                total.OutNum       += st.OutNum;
                total.OutMoney     += st.OutMoney;
                total.CurrentNum   += st.CurrentNum;
                total.CurrentMoney += st.CurrentMoney;
            }
            total.PaperName = "汇总";
            StoreList.Add(total);
            return(DataSource.ORMHelper.ModelListToTb <Store_month>(StoreList));
        }