Esempio n. 1
0
        public static bool Insert_GatePass(GatePassVM model, string dealerCode, ref string msg)
        {
            try
            {
                if (model.GatePassCode == "" || model.GatePassCode == null)
                {
                    strAutoCode = sysfun.AutoGen("GatePassTemp", "GatePassCode", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy"), dealerCode);
                }
                else
                {
                    strAutoCode = model.GatePassCode;
                    IsSaved     = true;
                    return(IsSaved);
                }

                SqlParameter[] GatePass_param =
                {
                    /*0*/ new SqlParameter("@DealerCode",   SqlDbType.Char,      5),

                    /*1*/ new SqlParameter("@GatePassCode", SqlDbType.Char,      8),
                    // /*2*/ new SqlParameter("@GatePassDate",SqlDbType.DateTime),
                    /*4*/ new SqlParameter("@TransCode",    SqlDbType.VarChar,   8),
                    /*3*/ new SqlParameter("@GatePassType", SqlDbType.Char,      1),
                    /*4*/ new SqlParameter("@Remarks",      SqlDbType.Char,    100),
                    /*6*/ new SqlParameter("@Module",       SqlDbType.VarChar,  50),
                    /*7*/ new SqlParameter("@UpdUser",      SqlDbType.Char,     50),
                    /*9*/ new SqlParameter("@UpdTerm",      SqlDbType.Char,     50),
                    /*8*/ new SqlParameter("@DelFlag",      SqlDbType.Char,      1),
                    /*4*/ new SqlParameter("@InvoiceNo",    SqlDbType.VarChar,   8),
                };
                GatePass_param[0].Value = dealerCode;
                GatePass_param[1].Value = strAutoCode;
                GatePass_param[2].Value = model.TransCode;
                GatePass_param[3].Value = "N";
                GatePass_param[4].Value = "";
                GatePass_param[5].Value = "Sales";
                GatePass_param[6].Value = AuthBase.UserId;
                GatePass_param[7].Value = GlobalVar.mUserIPAddress;
                GatePass_param[8].Value = "N";
                GatePass_param[9].Value = model.TransCode;
                if (sysfun.ExecuteSP_NonQuery("[Sp_Insert_GatePassTemp]", GatePass_param))
                {
                    IsSaved = true;
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                //ObjTrans.RollBackTransaction(ref Trans);
                //throw;
            }

            return(IsSaved);
        }
        public ActionResult Generate(GatePassVM gatePass)
        {
            ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());


            if (ModelState.IsValid)
            {
                var vehicleId = db.Vehicles.Where(e => e.RegistrationNo == gatePass.RegistrationNo).Select(e => e.Id).FirstOrDefault();


                DriverStatus dv = new DriverStatus();
                dv.UserId            = user.Id;
                dv.AssignedRequestId = gatePass.AssignedRequestId;
                dv.ConfigurationId   = gatePass.ConfigurationId;
                dv.OnTime            = DateTime.Now;

                VehicleStatus vs = new VehicleStatus();
                vs.VehicleId         = vehicleId;
                vs.AssignedRequestId = gatePass.AssignedRequestId;
                vs.ConfigurationId   = gatePass.ConfigurationId;
                vs.OnTime            = DateTime.Now;
                vs.UserId            = user.Id;

                if (gatePass.GatePassBy)
                {
                    var driverId = db.Employees.Where(e => e.UserId == dv.UserId).Select(e => e.Id).FirstOrDefault();
                    dv.EmployeeId = driverId;
                    vs.EmployeeId = dv.EmployeeId;
                }
                else
                {
                    var driverId = db.Employees.Where(e => e.EmpIdNo == gatePass.EmpIdNo && e.IsDriver == true).Select(e => e.Id).FirstOrDefault();
                    dv.EmployeeId = driverId;
                    vs.EmployeeId = dv.EmployeeId;
                }
                db.DriversStatuses.Add(dv);
                // db.SaveChanges();
                db.VehiclesStatuses.Add(vs);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            //ViewBag.AssignedRequestId = new SelectList(db.AssignedRequests, "Id", "UserId", driverStatus.AssignedRequestId);
            // ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "Name", driverStatus.EmployeeId);
            var status =
                db.Configurations.Include(e => e.ConfigurationType)
                .Where(e => e.ConfigurationType.Type == "DriverStatus");

            ViewBag.ConfigurationId = new SelectList(status, "Id", "Name");

            return(View());
        }
Esempio n. 3
0
        public JsonResult Insert_GatePass(GatePassVM DOMasterVM)
        {
            bool result = false;

            string msg = "Failed to save record..";

            Session["TransCode"] = DOMasterVM.TransCode;
            result = DeliveryOrderMethods.Insert_GatePass(DOMasterVM, Session["DealerCode"].ToString(), ref msg);

            if (result)
            {
                msg = "Successfully Added";
            }


            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }