Exemplo n.º 1
0
        public Boolean UpdateDataVMS(VMSDataModel model)
        {
            SqlConnection con = new SqlConnection(conString);

            try
            {
                SqlCommand com = new SqlCommand("SP_UpdateVMSData", con);
                com.CommandTimeout = 0;
                com.CommandType    = CommandType.StoredProcedure;

                com.Parameters.Add(new SqlParameter("@NIK", model.NIK));
                com.Parameters.Add(new SqlParameter("@Photo", model.Photo));
                com.Parameters.Add(new SqlParameter("@CardNo", model.CardNo));
                com.Parameters.Add(new SqlParameter("@Name", model.Name));
                com.Parameters.Add(new SqlParameter("@UnitBusiness", model.UnitBusiness));

                con.Open();
                com.ExecuteNonQuery();
            }
            catch (Exception err)
            {
                con.Close();
                return(false);
            }
            finally
            {
                con.Close();
            }

            return(true);
        }
Exemplo n.º 2
0
        public Boolean VMSAPIUpdateDataUser()
        {
            bool result  = false;
            var  client  = new RestClient("http://117.102.82.138");
            var  request = new RestRequest("erp/api_vms_update_data.php", Method.GET);

            request.AddParameter("hash", dataEncryption.Encrypt(DateTime.Now.ToString("yyyy-MM-dd"))); // adds to POST or URL querystring based on Method
            request.AddParameter("user", dataEncryption.Encrypt("api.koperasi.local"));
            request.AddParameter("date", DateTime.Now.ToString("yyyy-MM-dd"));

            var response = client.Execute(request);

            updateUserResult = response.Content;
            var          data  = (JObject)JsonConvert.DeserializeObject(response.Content);
            VMSDataModel model = new VMSDataModel();

            if (data["data"] != null)
            {
                foreach (var item in data["data"])
                {
                    model.NIK          = item[3].ToString();
                    model.Name         = item[1].ToString();
                    model.UnitBusiness = item[2].ToString();
                    model.CardNo       = item[0].ToString();
                    model.Photo        = item[4].ToString();

                    result = UpdateDataVMS(model);

                    if (!result)
                    {
                        return(result);
                    }
                }
            }

            return(result);
        }