Exemplo n.º 1
0
        public IHttpActionResult SaveItemClass(whic1 ItemClass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            int afRecCnt = ItemClassHelper.SaveItemClass(ItemClass);

            if (afRecCnt <= 0)
            {
                return(BadRequest());
            }
            return(Ok());
        }
Exemplo n.º 2
0
        public static int SaveItemClass(whic1 ItemClass)
        {
            var connection = ApiService.dbConnection;
            int afRecCnt   = 0;

            try
            {
                connection.Open();

                // get item class count
                int itemClassCnt = connection.ExecuteScalar <int>(qryItemClass.selectItemClassCount, new { ItemClassCode = ItemClass.ItemClassCode });
                if (itemClassCnt <= 0)
                {
                    // insert item class
                    afRecCnt = connection.Execute(qryItemClass.insertItemClass,
                                                  new
                    {
                        ItemClassCode = ItemClass.ItemClassCode,
                        Description   = ItemClass.Description,
                        Remark        = ItemClass.Remark,
                        WorkStation   = ApiService.HostName,
                        StatusCode    = ItemClass.StatusCode,
                        CreateBy      = ApiService.UserId,
                        UpdateBy      = ApiService.UserId
                    },
                                                  null, null, CommandType.StoredProcedure);
                }
                else
                {
                    // update item class
                    afRecCnt = connection.Execute(qryItemClass.updateItemClass,
                                                  new
                    {
                        ItemClassCode = ItemClass.ItemClassCode,
                        Description   = ItemClass.Description,
                        Remark        = ItemClass.Remark,
                        WorkStation   = ApiService.HostName,
                        StatusCode    = ItemClass.StatusCode,
                        UpdateBy      = ApiService.UserId
                    },
                                                  null, null, CommandType.StoredProcedure);
                }
            }
            catch (Exception) { throw; }
            finally { connection.Close(); }

            return(afRecCnt);
        }
Exemplo n.º 3
0
        public static whic1 GetItemClass(string ItemClassCode)
        {
            var   connection  = ApiService.dbConnection;
            whic1 myItemClass = null;

            try
            {
                connection.Open();

                // select item class
                myItemClass = connection.QueryFirst <whic1>(qryItemClass.selectItemClass, new { ItemClassCode });
            }
            catch (Exception) { throw; }
            finally { connection.Close(); }

            return(myItemClass);
        }