public ActionResult Create(CompanyPayType companyPayType) { companyPayType.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <CompanyPayType>(companyPayType); return(RedirectToAction("index")); }
public ActionResult Create(Customer customer) { customer.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <Customer>(customer); return(RedirectToAction("index")); }
// GET: CompanyPayType public ActionResult Index() { var payTypes = CompanyPayTypeHelper.PayTypeList(); var salaryPayType = payTypes.FirstOrDefault(i => i.Id == SalaryPayType); if (salaryPayType == null) { //初次加载,初始化薪资支出与进水支出类别,且不允许删除 List <CompanyPayType> payTypeMods = new List <CompanyPayType> { new CompanyPayType { Id = SalaryPayType, PayType = "员工薪资支出" }, new CompanyPayType { Id = BucketPayType, PayType = "进水支出" } }; MongoBase.Insert(payTypeMods); } ViewBag.flag = "payTypes"; return(View(payTypes)); }
public ActionResult CompanyCreate(CompanyPayRecord companyPayRecord) { //MongoDB采取的是UTC时间,而通常系统用的是Local时间(中国) companyPayRecord.TransTime = DateTime.SpecifyKind(companyPayRecord.TransTime, DateTimeKind.Utc); companyPayRecord.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <CompanyPayRecord>(companyPayRecord); return(RedirectToAction("CompanyRecord")); }
/// <summary> /// 工资发放 /// </summary> /// <param name="staffSalary"></param> /// <returns></returns> public ActionResult PaySalary(StaffSalary staffSalary) { //检查该月份该员工是否已经发过工资 var staffSal = SalaryHelper.CheckIfPaid(staffSalary.StaffId, staffSalary.SalaryMonth); if (staffSal != null) { TempData["CheckErr"] = "该员工" + staffSalary.SalaryMonth.Year + "-" + staffSalary.SalaryMonth.Month + "的薪资已经发放,请核查"; return(RedirectToAction("SalaryList")); } //获取该员工该薪资月的送水记录,统计提成用 var dailyRecords = DailyRecordHelper.DailyRecordList() .Where(item => item.VisitDate.Year == staffSalary.SalaryMonth.Year && item.VisitDate.Month == staffSalary.SalaryMonth.Month && item.StaffId == staffSalary.StaffId); //判断是否需要薪资发放类型 var salaryType = CompanyPayTypeHelper.GetById(SalaryPayType); if (salaryType == null) { MongoBase.Insert(new CompanyPayType { Id = SalaryPayType, PayType = "员工薪资支出" }); } staffSalary.Id = ObjectId.NewObjectId().ToString(); staffSalary.Commission = dailyRecords.Sum(i => i.SendBucketAmount) * Commission(); //提成 MongoBase.Insert(staffSalary); //公司当月支出增多相应金额 CompanyPayRecord companyRecord = new CompanyPayRecord() { Id = ObjectId.NewObjectId().ToString(), IsPayType = true, PayTypeId = SalaryPayType, StaffId = staffSalary.StaffId, TransSum = staffSalary.Salary, TransTime = Convert.ToDateTime(staffSalary.SalaryMonth + "-28") }; MongoBase.Insert(companyRecord); return(RedirectToAction("SalaryList")); }
public ActionResult Create(Products product) { //重名判断 var pro = ProductHelper.GetByName(product.ProductName); if (pro != null) { TempData["isRepeat"] = true; } else { product.Id = ObjectId.NewObjectId().ToString(); product.UpdateTime = DateTime.Now; MongoBase.Insert(product); } return(RedirectToAction("index")); }
public ActionResult Create(Factory factory) { factory.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <Factory>(factory); return(RedirectToAction("index")); }
public ActionResult Create(Staff staff) { staff.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <Staff>(staff); return(RedirectToAction("index")); }
public ActionResult Create(StaffCustomer staffCustomer) { staffCustomer.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert(staffCustomer); return(RedirectToAction("Index")); }
/// <summary> /// 添加日常记账 /// </summary> /// <param name="dailyRecord"></param> /// <param name="hidBuckets"></param> /// <returns></returns> public ActionResult CreateDailyWrite(DailyRecord dailyRecord, string[] hidBuckets) { //MongoDB采取的是UTC时间,而通常系统用的是Local时间(中国) dailyRecord.VisitDate = DateTime.SpecifyKind(dailyRecord.VisitDate, DateTimeKind.Utc); string[] bucketPams = hidBuckets[0].Split(','); if (bucketPams.Length == 1) { if (dailyRecord.EarnMonthEndPrice >= 0 || dailyRecord.EarnWaterCardPrice >= 0) { //添加日常记录 dailyRecord.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert(dailyRecord); //添加公司下次送水日期 Customer customer = CustomerHelper.GetById(dailyRecord.CustomerId); if (customer != null) { customer.NextDate = dailyRecord.NextDate; customer.NotifyFlag = 1;//开启通知 CustomerHelper.Update(customer); } } } else { for (int i = 0; i < bucketPams.Length; i++) { var t = i % 3; if (t == 0) { dailyRecord.SendProductId = bucketPams[i]; } else if (t == 1) { dailyRecord.SendBucketAmount = int.Parse(bucketPams[i]); } else { dailyRecord.ReceiveEmptyBucketAmount = int.Parse(bucketPams[i]); } if ((i + 1) % 3 == 0) { ////完成一个产品 //更新库存信息 var product = ProductHelper.GetById(dailyRecord.SendProductId); product.StockRemain += dailyRecord.SendBucketAmount; //桶装水库存增加 product.BucketStockRemain += dailyRecord.ReceiveEmptyBucketAmount; //空桶库存增加 ProductHelper.Update(product); //添加一条日常记录 dailyRecord.Id = ObjectId.NewObjectId().ToString(); //同一人在同一公司,资金交易只记一笔(避免汇总数据double);附属产品只记一笔 if (i > 2) { dailyRecord.EarnDeposit = 0; dailyRecord.PayDeposit = 0; dailyRecord.EarnMonthEndPrice = 0; dailyRecord.EarnWaterCardPrice = 0; dailyRecord.WaterDispenser = 0; dailyRecord.WaterHolder = 0; dailyRecord.PushPump = 0; dailyRecord.WaterDispenserBack = 0; dailyRecord.WaterHolderBack = 0; dailyRecord.PushPumpBack = 0; } MongoBase.Insert(dailyRecord); } } } return(RedirectToAction("DailyRecord")); }