コード例 #1
0
        public int Update(FixturePart_VM Model)
        {
            int result = 0;

            try
            {
                using (var db = new DBConnection())
                {
                    var par = new SqlParameter[] {
                        new SqlParameter("@p_FixturePartID", GetDBNULL(Model.FixturePartID)),
                        new SqlParameter("@p_FixtureID", GetDBNULL(Model.FixtureID)),
                        new SqlParameter("@p_PartID", GetDBNULL(Model.PartID)),
                        new SqlParameter("@p_Quantity", GetDBNULL(Model.Quantity)),

                        new SqlParameter("@p_EndUserID", GetDBNULL(Model.CurrentEndUserID)),
                        new SqlParameter("@p_UserRoleID", GetDBNULL(Model.CurrentUserRoleID)),
                        new SqlParameter("@p_ScreenID", GetDBNULL(Model.CurrentScreenID)),
                        new SqlParameter("@p_AccessPoint", GetDBNULLString(Model.AccessPoint))
                    };

                    db.ExecuteNonQueryRollBack("UpdateFixturePart", par);
                }
            }
            catch (Exception ex)
            {
                logger.Error("FixturePartRepository_Update Error: ", ex);
                throw;
            }

            return(result);
        }
コード例 #2
0
        public List <FixturePart_VM> GetData(FixturePart_VM Model)
        {
            var query = new List <FixturePart_VM>();

            try
            {
                using (var db = new DBConnection())
                {
                    var ds = db.ExecuteDataSet("GetFixturePart", new SqlParameter[] {
                        new SqlParameter("@p_FixturePartID", GetDBNULL(Model.FixturePartID)),
                        new SqlParameter("@p_FixtureID", GetDBNULLString(Model.FixtureID)),
                        new SqlParameter("@p_PartID", GetDBNULLString(Model.PartID)),
                        new SqlParameter("@p_Quantity", GetDBNULL(Model.Quantity))
                    });

                    query = ConvertToList <FixturePart_VM>(ds.Tables[0]);
                }
            }
            catch (Exception ex)
            {
                logger.Error("FixturePartRepository_GetData Error: ", ex);
                throw;
            }

            return(query);
        }
コード例 #3
0
        public JsonResult AddUpdateData(FixturePart_VM Model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    GetUserInfo(Model);

                    if (Model.FixturePartID == 0 || Model.FixturePartID == null)
                    {
                        var data = _FixturePartRepo.Add(Model);
                        return(GetAddEditDeleteResponse(data, "Add"));
                    }
                    else if (Model.FixturePartID > 0)
                    {
                        var data = _FixturePartRepo.Update(Model);
                        return(GetAddEditDeleteResponse(data, "Update"));
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("FixturePartController_AddUpdateData Error: ", ex);
                    return(GetAddEditErrorException(ex));
                }
            }
            return(GetModelStateIsValidException(ViewData));
        }
コード例 #4
0
 public JsonResult GetData(FixturePart_VM Model)
 {
     try
     {
         List <FixturePart_VM> vm = _FixturePartRepo.GetData(Model);
         return(GetDataResponse(vm));
     }
     catch (Exception ex)
     {
         return(GetDataResponseException(ex));
     }
 }
コード例 #5
0
        public JsonResult Delete(FixturePart_VM Model)
        {
            if (CheckAccess(Model.CurrentScreenID, "Fixture Part"))
            {
                try
                {
                    GetUserInfo(Model);

                    if (Model.FixturePartID > 0 && Model.FixturePartID != null)
                    {
                        var data = _FixturePartRepo.Delete(Model);
                        return(GetAddEditDeleteResponse(data, "Delete"));
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("FixturePartController_Delete Error: ", ex);
                    return(GetAddEditErrorException(ex));
                }
            }
            return(GetModelStateIsValidException(ViewData));
        }
コード例 #6
0
        public int Add(FixturePart_VM Model)
        {
            int result = 0;

            try
            {
                using (var db = new DBConnection())
                {
                    var output = new SqlParameter("@p_FixturePartID", 0)
                    {
                        Direction = ParameterDirection.Output
                    };

                    var par = new SqlParameter[] {
                        new SqlParameter("@p_FixtureID", GetDBNULL(Model.FixtureID)),
                        new SqlParameter("@p_PartID", GetDBNULL(Model.PartID)),
                        new SqlParameter("@p_Quantity", GetDBNULL(Model.Quantity)),

                        new SqlParameter("@p_EndUserID", GetDBNULL(Model.CurrentEndUserID)),
                        new SqlParameter("@p_UserRoleID", GetDBNULL(Model.CurrentUserRoleID)),
                        new SqlParameter("@p_ScreenID", GetDBNULL(Model.CurrentScreenID)),
                        new SqlParameter("@p_AccessPoint", GetDBNULLString(Model.AccessPoint)),
                        output
                    };

                    db.ExecuteNonQueryRollBack("AddFixturePart", par);
                    result = Convert.ToInt32(output.Value);
                }
            }
            catch (Exception ex)
            {
                logger.Error("FixturePartRepository_Add Error: ", ex);
                throw;
            }

            return(result);
        }