예제 #1
0
 private void Txt_CustomerPic_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)13)
     {
         Txt_CustomerTlp.Focus();
     }
 }
예제 #2
0
        private bool validateform()
        {
            bool output = true;

            if (Txt_CustomerNama.Text == "")
            {
                output = false;
                MessageBox.Show("Nama Pelanggan harus diisi", "Perhatian", MessageBoxButtons.OK);
                Txt_CustomerNama.Focus();
            }
            else
            if (Txt_CustomerTlp.Text == "" && Txt_CustomerEmail.Text == "")
            {
                output = false;
                MessageBox.Show("No. Telepon/Email harus diisi", "Perhatian", MessageBoxButtons.OK);
                Txt_CustomerTlp.Focus();
            }
            try
            {
                using (IDbConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[db].ConnectionString))
                {
                    var p = new DynamicParameters();
                    p.Add("@Cust_Id", cust_Id);
                    p.Add("@CustomerNama", Txt_CustomerNama.Text);

                    var Hitung = connection.ExecuteScalar <int>("dbo.SpCust_Cek_Nama", p, commandType: CommandType.StoredProcedure);
                    if (Hitung == 1)
                    {
                        output = false;
                        MessageBox.Show($"Nama Pelanggan {Txt_CustomerNama.Text} sudah ada", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        Txt_CustomerNama.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(output);
        }