コード例 #1
0
 private void btnSimpan_Click(object sender, EventArgs e)
 {
     try
     {
         if (Helpers.GetValidate(panel1) == true)
         {
             if (statusDisplay == 1)
             {
                 if (Rekanan.InsertData(SetData(1)) == true)
                 {
                     Helpers.MsgBoxSave();
                 }
             }
             else if (statusDisplay == 2)
             {
                 if (Rekanan.UpdateDate(SetData(2)) == true)
                 {
                     Helpers.MsgBoxSave();
                 }
             }
             PreCreateDisplay();
         }
     }
     catch (Exception ex)
     {
         Helpers.MsgBoxError(ex.Message);
     }
 }
コード例 #2
0
        public static Boolean InsertData(Rekanan rekanan)
        {
            string sql = "Insert into Rekanan values('" + rekanan.IdRekanan + "','" + rekanan.TipeRekanan + "','" + rekanan.NamaRekanan + "'" +
                         ",'" + rekanan.Alamat + "','" + rekanan.NoTlp + "','" + rekanan.IsActive + "')";

            try
            {
                DataAccess.ExecuteNonQuery(sql);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
コード例 #3
0
        int statusDisplay; //1 for create,2 for edit

        Rekanan SetData(byte status)
        {
            //1 for create,2 for edit
            Rekanan myData = new Rekanan();

            switch (status)
            {
            case (1):
            {
                myData.IdRekanan   = Rekanan.GenerateId();
                myData.TipeRekanan = cmbTipe.Text == "Supplier" ? Convert.ToChar("S") : Convert.ToChar("P");
                myData.NamaRekanan = txtNama.Text;
                myData.Alamat      = txtAlamat.Text;
                myData.NoTlp       = txtTlp.Text;
                if (rdAktif.Checked == true)
                {
                    myData.IsActive = true;
                }
                if (rdTdkAktif.Checked == true)
                {
                    myData.IsActive = false;
                }
            }
            break;

            case (2):
            {
                myData.IdRekanan   = myID;
                myData.TipeRekanan = cmbTipe.Text == "Supplier" ? Convert.ToChar("S") : Convert.ToChar("P");
                myData.NamaRekanan = txtNama.Text;
                myData.Alamat      = txtAlamat.Text;
                myData.NoTlp       = txtTlp.Text;
                if (rdAktif.Checked == true)
                {
                    myData.IsActive = true;
                }
                if (rdTdkAktif.Checked == true)
                {
                    myData.IsActive = false;
                }
            }
            break;
            }
            return(myData);
        }
コード例 #4
0
        public static Boolean UpdateDate(Rekanan rekanan)
        {
            string sql = "Update Rekanan set TipeRekanan = '" + rekanan.TipeRekanan + "',NamaRekanan = '" + rekanan.NamaRekanan + "'" +
                         ",Alamat = '" + rekanan.Alamat + "',NoTlp = '" + rekanan.NoTlp + "',IsActive = " + rekanan.IsActive
                         + " Where IdRekanan= " + rekanan.IdRekanan + "";

            try
            {
                DataAccess.ExecuteNonQuery(sql);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
コード例 #5
0
 void ListDataBySearch()
 {
     dgv.DataSource = Rekanan.GetListRekananByNama(txtCari.Text, cmbCari.Text);
     dgv.ReadOnly   = true;
     HeaderGrid();
 }
コード例 #6
0
 void ListData()
 {
     dgv.DataSource = Rekanan.GetListRekanan(1);
     dgv.ReadOnly   = true;
     HeaderGrid();
 }