Esempio n. 1
0
        private void pbBack_Click(object sender, EventArgs e)
        {
            FCashierMenu fc = new FCashierMenu();

            fc.Show();
            this.Hide();
        }
Esempio n. 2
0
        private void pbLogin_Click(object sender, EventArgs e)
        {
            int    result = 0;
            string info = "";
            string username, password;

            username = txtUser.Text;
            password = txtPass.Text;
            try
            {
                info = con.openconnection();
                if (info == "OK")
                {
                    string     query = "select count(*) from AccessLogin where Username = @Username and UPassword = @UPassword and isAdmin = '0'";
                    SqlCommand com   = new SqlCommand(query, con.con);
                    com.Parameters.AddWithValue("@Username", username);
                    com.Parameters.AddWithValue("@UPassword", password);
                    SqlDataReader dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        result = Convert.ToInt32(dr[0]);
                    }
                    dr.Close();
                }
                if (con.closeconnection() == "OK")
                {
                    info = "OK";
                }
            }
            catch (Exception xe)
            {
                MessageBox.Show(xe.Message);
            }
            if (result > 0)
            {
                MessageBox.Show("Welcome, " + username + ". Have a nice day :)", "Login Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FCashierMenu fcm = new FCashierMenu();
                fcm.Show();
                this.Hide();
                counter = 0;
            }
            else
            {
                counter += 1;
                if (counter < 3)
                {
                    lblError.Visible = true;
                    txtUser.Focus();
                    txtUser.Clear();
                    txtPass.Clear();
                }
            }
        }
Esempio n. 3
0
 private void pbBack_Click(object sender, EventArgs e)
 {
     if (dgvRecipe.Rows.Count > 0)
     {
         DialogResult result = MessageBox.Show("Are you sure the transaction has been completed?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             insertdgvrecipe();
             FCashierMenu fcm = new FCashierMenu();
             fcm.Show();
             this.Hide();
         }
     }
     else
     {
         FCashierMenu fcm = new FCashierMenu();
         fcm.Show();
         this.Hide();
     }
 }
Esempio n. 4
0
        private void pbSave_Click(object sender, EventArgs e)
        {
            if (txtDose.Text == "" || txtSubtotal.Text == "")
            {
                MessageBox.Show("Please fill the data");
            }
            else
            {
                if (txtRD.Text == "full")
                {
                    MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    FCashierMenu fcm = new FCashierMenu();
                    fcm.Show();
                    this.Hide();
                }
                else
                {
                    if (validasidrug() == 0)
                    {
                        if (Convert.ToInt32(strqty) < Convert.ToInt32(txtQty.Text))
                        {
                            //obat kurang
                            MessageBox.Show("less drug");
                        }
                        else if (expdate == date)
                        {
                            MessageBox.Show("Can not save record because drug has been expired");
                            txtDrug.Clear();
                        }
                        else
                        {
                            DialogResult result = MessageBox.Show("Are your sure want to add data " + txtDrug.Text + "?", "Add", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (result == DialogResult.Yes)
                            {
                                string drugname = "";
                                string info     = "";
                                try
                                {
                                    info = con.openconnection();
                                    if (info == "OK")
                                    {
                                        string        query = "select * from Recipe.Drug where Id_Drug ='" + txtDrug.Text + "'";
                                        SqlCommand    com   = new SqlCommand(query, con.con);
                                        SqlDataReader sdr   = com.ExecuteReader();
                                        while (sdr.Read())
                                        {
                                            //string idpay = dr["Id_Payment"].ToString();
                                            drugname = sdr["DrugName"].ToString();
                                        }
                                        sdr.Close();
                                    }
                                    if (con.closeconnection() == "OK")
                                    {
                                        info = "OK";
                                    }
                                }
                                catch (Exception xe)
                                {
                                    MessageBox.Show(xe.Message);
                                }
                                dr             = dt.NewRow();
                                dr["ID Drug"]  = txtDrug.Text;
                                dr["DrugName"] = drugname;
                                dr["Qty"]      = txtQty.Text;
                                dr["Dose"]     = txtDose.Text;
                                dt.Rows.Add(dr);
                                dgvRecipe.DataSource = dt;

                                txtRD.Text = autoid();
                                txtDrug.Clear();
                                txtQty.Clear();
                                txtDose.Clear();
                                txtSubtotal.Clear();
                                isidgvdrug();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please fill in the data");
                    }
                }
            }
        }