Example #1
0
        public static void GenerateVoucher()
        {
            List <Dmg_Goods_Dtl> VoucherForDmg = model.Dmg_Goods_Dtl.Where(x => x.Details == "pending").ToList();;
            var            xy          = model.Dmg_Goods_Dtl.Where(x => x.Details == "pending").GroupBy(x => new { x.Item_number }).Select(x => new { x.Key.Item_number, v = x.Sum(y => y.Damage_Qnty) }).ToList();
            List <Voucher> Voucherlist = xy.Select(x => new Voucher(x.Item_number, (int)x.v)).ToList <Voucher>();

            if (Voucherlist.Count != 0)
            {
                foreach (var item in Voucherlist)
                {
                    Voucher_details newVoucher = new Voucher_details();
                    newVoucher.Item_Number  = item.Item_Number;
                    newVoucher.Approve_ID   = "STR001";
                    newVoucher.Voucher_Date = System.DateTime.Now;
                    newVoucher.Quantity     = item.DmgQuantity;
                    newVoucher.Amount       = item.DmgQuantity * GetItemPrice(item.Item_Number);
                    newVoucher.Status       = "Pending";
                    model.Voucher_details.Add(newVoucher);
                    model.SaveChanges();
                }
            }
            foreach (Dmg_Goods_Dtl dmg in VoucherForDmg)
            {
                dmg.Details = "done";
            }
            SendVoucher();
        }
Example #2
0
        public static void createVoucher(string description, int quantity, Employee emp)
        {
            Voucher_details newVoucher = new Voucher_details();

            newVoucher.Employee_ID = "STR003";
            //newVoucher.Damage_ID = (from x in model.Dmg_Goods_Dtl select x.Dmg_ID).Last();
            newVoucher.Voucher_Date = System.DateTime.Today;
            newVoucher.Amount       = 34;
            model.Voucher_details.Add(newVoucher);
            model.SaveChanges();
        }