Ejemplo n.º 1
0
        public int AddEditDivisi(Divisi divisi)
        {
            string sqlCommand = "spAddEditDivisi";

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@id", divisi.id);
            parameters.Add("@nm", divisi.nm);
            parameters.Add("@alm1", divisi.alm1);
            parameters.Add("@alm2", divisi.alm2);
            parameters.Add("@tlp", divisi.tlp);
            parameters.Add("@ct_person", divisi.ct_person);
            parameters.Add("@statusx", divisi.statusx);
            parameters.Add("@ctk_hrg", divisi.ctk_hrg);
            parameters.Add("@npwp", divisi.npwp);
            parameters.Add("@k_payment", divisi.k_payment);
            parameters.Add("@countx", divisi.countx);
            parameters.Add("@user_entry", divisi.user_entry);
            parameters.Add("@cust_id", divisi.cust_id);

            using (SqlCommand cmd = General.GetCommand(sqlCommand, parameters))
            {
                if (cmd.Connection.State == ConnectionState.Closed)
                {
                    cmd.Connection.Open();
                }

                return(cmd.ExecuteNonQuery());
            }
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Divisi divisi = db.Divisis.Find(id);

            db.Divisis.Remove(divisi);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "DivisiID,NamaDivisi")] Divisi divisi)
 {
     if (ModelState.IsValid)
     {
         db.Entry(divisi).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(divisi));
 }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "DivisiID,NamaDivisi")] Divisi divisi)
        {
            if (ModelState.IsValid)
            {
                db.Divisis.Add(divisi);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(divisi));
        }
Ejemplo n.º 5
0
        public JsonResult AddEditDivisi(Divisi divisi)
        {
            if (ModelState.IsValid)
            {
                db.AddEditDivisi(divisi);
            }

            string status  = divisi.id != Guid.Empty ? "updated" : "saved";
            string message = $"Term Invoice has been {status} successfully";

            return(Json(message, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
 // PUT: api/Divisi/5
 public IHttpActionResult Put(Divisi divisi)
 {
     try
     {
         divisiBL.UpdateDivisi(divisi);
         return(Ok());
     }
     catch (Exception ex)
     {
         Debug.Write("Error : " + ex.Message);
         return(BadRequest(ex.Message));
     }
 }
Ejemplo n.º 7
0
        // GET: Divisis/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Divisi divisi = db.Divisis.Find(id);

            if (divisi == null)
            {
                return(HttpNotFound());
            }
            return(View(divisi));
        }
 public void UpdateDivisi(Divisi divisi)
 {
     using (DivisiDAL divDal = new DivisiDAL())
     {
         try
         {
             divDal.UpdateDivisi(divisi);
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
Ejemplo n.º 9
0
 public void InsertDivisi(Divisi divisi)
 {
     using (OracleConnection conn = new OracleConnection(GetConnectionString()))
     {
         string strSql = @"insert into Erick.Divisi(NamaDivisi) values(:NamaDivisi)";
         try
         {
             conn.Execute(strSql, new { NamaDivisi = divisi.NamaDivisi });
         }
         catch (OracleException oEx)
         {
             throw new Exception("Error : " + oEx.Message);
         }
     }
 }
Ejemplo n.º 10
0
 public void UpdateDivisi(Divisi divisi)
 {
     using (OracleConnection conn = new OracleConnection(GetConnectionString()))
     {
         string strSql = @"update Erick.Divisi set NamaDivisi=:NamaDivisi where DivisiID=:DivisiID";
         try
         {
             conn.Execute(strSql,
                          new { NamaDivisi = divisi.NamaDivisi, DivisiID = divisi.DivisiID });
         }
         catch (OracleException oEx)
         {
             throw new Exception("Error: " + oEx.Message);
         }
     }
 }
Ejemplo n.º 11
0
        public Divisi GetDivisiById(Guid id)
        {
            string sqlCommand = "spGetById";

            using (SqlCommand cmd = General.GetCommand(sqlCommand))
            {
                cmd.Parameters.Add("@TableName", SqlDbType.NVarChar, 50).Value  = Table.m_div;
                cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier, 16).Value = id;

                using (SqlDataAdapter sdAdapter = new SqlDataAdapter(cmd))
                {
                    DataSet ds = new DataSet();
                    sdAdapter.Fill(ds, "m_div");

                    Divisi divisi = new Divisi();
                    foreach (DataRow dr in ds.Tables["m_div"].Rows)
                    {
                        divisi.id         = !string.IsNullOrEmpty(dr["id"].ToString()) ? (Guid?)Guid.Parse(dr["id"].ToString()) : null;
                        divisi.cust_id    = Guid.Parse(dr["cust_id"].ToString());
                        divisi.nm         = dr["nm"].ToString();
                        divisi.alm1       = dr["alm1"].ToString();
                        divisi.alm2       = dr["alm2"].ToString();
                        divisi.tlp        = dr["tlp"].ToString();
                        divisi.ct_person  = dr["ct_person"].ToString();
                        divisi.statusx    = dr["statusx"].ToString();
                        divisi.ctk_hrg    = dr["ctk_hrg"].ToString();
                        divisi.npwp       = dr["npwp"].ToString();
                        divisi.k_payment  = dr["k_payment"].ToString();
                        divisi.countx     = !string.IsNullOrEmpty(dr["countx"].ToString()) ? (int?)int.Parse(dr["countx"].ToString()) : null;
                        divisi.user_entry = dr["user_entry"].ToString();
                    }

                    return(divisi);
                }
            }
        }