Exemplo n.º 1
0
        private bool validateform()
        {
            bool output = true;
            int  hrg_jual = 0, min_qty = 0, cogs_awal = 0;
            bool valid_Hrg_Jual  = int.TryParse(Txt_Inv_Hrg_Jual.Text, out hrg_jual);
            bool valid_min_qty   = int.TryParse(Txt_Inv_Min_Qty.Text, out min_qty);
            bool valid_cogs_awal = int.TryParse(Txt_Inv_Cogs_Awal.Text, out cogs_awal);

            if (Txt_Inv_Nama.Text == "")
            {
                output = false;
                MessageBox.Show("Nama Barang harus diisi", "Perhatian", MessageBoxButtons.OK);
                Txt_Inv_Nama.Focus();
            }
            else
            if (!valid_Hrg_Jual)
            {
                output = false;
                MessageBox.Show("Hrg Jual salah", "Perhatian", MessageBoxButtons.OK);
                Txt_Inv_Hrg_Jual.Focus();
            }
            else
            if (!valid_min_qty)
            {
                output = false;
                MessageBox.Show("Qty Minimum salah", "Perhatian", MessageBoxButtons.OK);
                Txt_Inv_Min_Qty.Focus();
            }
            else
            if (!valid_cogs_awal)
            {
                output = false;
                MessageBox.Show("Hrg Pokok Awal salah", "Perhatian", MessageBoxButtons.OK);
                Txt_Inv_Cogs_Awal.Focus();
            }

            try
            {
                using (IDbConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[db].ConnectionString))
                {
                    var p = new DynamicParameters();
                    p.Add("@Inv_Id", inv_Id);
                    p.Add("@Inv_Nama", Txt_Inv_Nama.Text);

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

                        Txt_Inv_Nama.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(output);
        }
Exemplo n.º 2
0
 //string.Format("{0:n0}", double.Parse(Txt_Inv_Cogs_Awal.Text));
 private void InvMain_Load(object sender, EventArgs e)
 {
     ViewGrid();
     Hapus();
     Btn_Save.Text = "Save";
     Txt_Inv_Nama.Focus();
 }
Exemplo n.º 3
0
 private void Btn_Cancel_Click(object sender, EventArgs e)
 {
     inv_Id = 0;
     Hapus();
     Btn_Save.Text      = "Save";
     Txt_Search.Enabled = true;
     Txt_Inv_Nama.Focus();
 }