Exemplo n.º 1
0
 private void FormWarrantView_Load(object sender, EventArgs e)
 {
     if (dataSource == null)
     {
         DateTime dt = DateTime.Now;
         DataSource = WarrantVwServices.List(new Db(DbServices.ConnectionString));
         slblEllapsedTimeValue.Text = (DateTime.Now.Subtract(dt).TotalMilliseconds / 1000).ToString();
     }
 }
Exemplo n.º 2
0
        // GET: User/EmployeeLoans
        public ActionResult Index()
        {
            ViewBag.EmployeeWarrants = employeeWarrants;
            WarrantVwViewModel model  = new WarrantVwViewModel();
            WarrantVwFilter    filter = new WarrantVwFilter();

            filter.EmployeeId = int.Parse(CurrentUser.UserName);
            model.List        = WarrantVwServices.Get(filter, db);
            return(View(model));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Returns a list of WarrantVw objects
 /// </summary>
 /// <returns></returns>
 public ActionResult Index(WarrantVwViewModel Model)
 {
     if (Model.Filter.HasCriteria)
     {
         Db db = new Db(DbServices.ConnectionString);
         Model.List = WarrantVwServices.Get(Model.Filter, db);
     }
     else
     {
         Model.List = new List <WarrantVw>();
     }
     return(View(Model));
 }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WarrantVwViewModel warrantVwViewModel = new WarrantVwViewModel();

            Db db = new Db(DbServices.ConnectionString);

            // warrantVwViewModel.Instance = WarrantVwServices.Get(id.Value, db);
            warrantVwViewModel.Instance = WarrantVwServices.GetChildren(id.Value, db);
            if (warrantVwViewModel.Instance == null)
            {
                return(HttpNotFound());
            }


            return(View(warrantVwViewModel));
        }
        public ActionResult CreateWarrant(WarrantVwViewModel model)
        {
            WarrantVwViewModel Model = new WarrantVwViewModel();

            try
            {
                EmployeeVw employee = EmployeeVwServices.Get(model.Instance.DebtEmployeeId);
                if (employee == null)
                {
                    TempData["Failure"] = "الرقم الذاتي غير صحيح";
                    Model.List          = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);
                    return(PartialView("_WarrantsList", Model));
                }
                // check if this employee is not the debt employee
                Debt d = DebtServices.Get(model.Instance.DebtId, db);
                if (d != null)
                {
                    if (d.Employee == model.Instance.DebtEmployeeId)
                    {
                        TempData["Failure"] = "لا يمكن أن يكفل الموظف نفسه";
                        Model.List          = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);
                        return(PartialView("_WarrantsList", Model));
                    }
                }


                // check if this employee has been added as a garantaur
                Warrant ewarrant = WarrantServices.GetByDebt_EmployeeFirstOrNull(model.Instance.DebtId, model.Instance.DebtEmployeeId);
                if (ewarrant != null)
                {
                    TempData["Failure"] = "هذا الموظف هو كفيل حالياً لهذه المديونية";
                }
                else
                {
                    Warrant w = new Warrant()
                    {
                        Debt     = model.Instance.DebtId,
                        Employee = model.Instance.DebtEmployeeId,
                        IsActive = model.Instance.IsActive,
                        Notes    = model.Instance.Notes
                    };
                    w = WarrantServices.Insert(CurrentUserId, w, db);
                }

                Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);

                return(PartialView("_WarrantsList", Model));
            }
            catch (CfException cfex)
            {
                TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                //return Json(new { status = false, message = cfex.ErrorDefinition.LocalizedMessage }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                TempData["Failure"] = ex.Message;
                //return Json(new { status = false, message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
            Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);
            return(PartialView("_WarrantsList", Model));
        }