Exemplo n.º 1
0
        private static void SetToBalanced(DetailDetailCompta line)
        {
            var items = from detail in db.DetailComptas
                        where
                        detail.id == line.OID
                        select detail;

            foreach (var item in items)
            {
                item.Balanced = true;
            }
            db.SubmitChanges();
        }
Exemplo n.º 2
0
        private bool InsertDetailsDetails(int itemOID, int modelId)
        {
            bool results  = true;
            int  detailId = 0;

            if (modelId.Equals((int)IWSLookUp.ComptaMasterModelId.Payment) ||
                modelId.Equals((int)IWSLookUp.ComptaMasterModelId.Settlement))
            {
                results = false;
                try
                {
                    var xv = db.DetailComptas;
                    if (xv.Any())
                    {
                        detailId = db.DetailComptas.Max(i => i.id);
                    }
                    else
                    {
                        detailId = 0;
                    }
                    detailId += 1;

                    var items = IWSLookUp.GetNewLineDetailDetail(detailId, itemOID, modelId);
                    foreach (var item in items)
                    {
                        DetailDetailCompta xc = new DetailDetailCompta()
                        {
                            TransId = item.TransId,
                            OID     = item.OID,
                            Amount  = item.Amount,
                            ModelId = item.ModelId
                        };
                        db.DetailDetailComptas.InsertOnSubmit(xc);// (DetailDetailCompta)item);
                    }
                    results = true;
                }
                catch (Exception e)
                {
                    IWSLookUp.LogException(e);
                }
            }
            return(results);
        }
Exemplo n.º 3
0
        public ActionResult DetailDetailGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] DetailDetailCompta line, int transId)
        {
            decimal leftToPay = IWSLookUp.GetLeftToPay(line.OID);
            int     modelId   = (int)Session["Modelid"];
            var     model     = db.DetailDetailComptas;

            line.TransId           = transId;
            line.ModelId           = modelId;
            ViewData["lineDetail"] = line;
            if (leftToPay >= line.Amount)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        model.InsertOnSubmit(line);
                        if (line.Amount > 0)
                        {
                            db.SubmitChanges();
                            if (IWSLookUp.CheckIfBalanced(line.OID))
                            {
                                SetToBalanced(line);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ViewData["GenericError"] = e.Message;
                    }
                }
                else
                {
                    ViewData["GenericError"] = IWSLookUp.GetModelSateErrors(ModelState);
                }
            }
            else
            {
                ViewData["GenericError"] = IWSLocalResource.LeftToPay + leftToPay.ToString("N2", CultureInfo.GetCultureInfo(Thread.CurrentThread
                                                                                                                            .CurrentUICulture.Name).NumberFormat) + " " +
                                           IWSLocalResource.LeftToPayEnd;
            }
            return(PartialView("DetailDetailGridViewPartial", IWSLookUp.GetDetailDetailCompta(transId, modelId)));
        }