/// <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); }
public static Store_month GetPaperMonthStore(int year, int month, int PaperId) { string where = " Year='" + year.ToString() + "' and Month='" + month.ToString() + "' and PaperId='" + PaperId.ToString() + "'"; DataTable dt = GetDataTable(where); if (dt != null && dt.Rows.Count > 0) { Store_month result = DataSource.ORMHelper.RowToModel <Store_month>(dt.Rows[0]); if (result != null) { return(result); } } return(null); }
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)); }
public static int Update(Store_month paper) { return(DataSource.ORMHelper.UpdateModelById <Store_month>(paper)); }