Ejemplo n.º 1
0
        private void dispStock_Click(object sender, EventArgs e)
        {
            StockDisp stockDisp = new StockDisp(this.status);

            stockDisp.Show();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
                builder.DataSource     = "medic-server.database.windows.net";
                builder.UserID         = "medic_admin";
                builder.Password       = "******";
                builder.InitialCatalog = "MedicAppDB";

                using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                {
                    string query = "select * from t_user";

                    using (SqlCommand sqlCommand = new SqlCommand(query, connection))
                    {
                        connection.Open();
                        using (SqlDataReader reader = sqlCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (tb_username.Text == reader["username"].ToString() && tb_password.Text == reader["password"].ToString())
                                {
                                    StringBuilder msg = new StringBuilder();
                                    msg.Append("Hoşgeldiniz: ");
                                    msg.Append(tb_username.Text);
                                    msg.Append("\nStatü: ");
                                    msg.Append(reader["status"]);
                                    MessageBox.Show(msg.ToString(), "Bilgi", MessageBoxButtons.OK);
                                    switch (reader["status"])
                                    {
                                    case "ECZ":
                                        this.Hide();
                                        MedicineDisplayECZ ecz = new MedicineDisplayECZ();
                                        ecz.status = reader["status"].ToString();
                                        ecz.Show();
                                        break;

                                    case "KLF":
                                        this.Hide();
                                        MedicineDisplayECZ eck = new MedicineDisplayECZ();
                                        eck.status = reader["status"].ToString();
                                        eck.Show();
                                        break;

                                    case "STK":
                                        this.Hide();
                                        StockDisp stock = new StockDisp(reader["status"].ToString());
                                        stock.Show();
                                        break;
                                    }
                                }
                                else if (tb_username.Text != reader["username"].ToString() && tb_password.Text == reader["password"].ToString())
                                {
                                    MessageBox.Show("Kullanıcı adı yanlış.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    break;
                                }
                                else if (tb_username.Text == reader["username"].ToString() && tb_password.Text != reader["password"].ToString())
                                {
                                    MessageBox.Show("Şifre yanlış.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }