private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (combobox.SelectedItem == null)
            {
                MessageBox.Show("Please choose an option");
            }
            else if (combobox.SelectedItem.Equals("Staff"))
            {
                /*StaffWindow objStaffWindow = new StaffWindow();
                 * objStaffWindow.Show();
                 * this.Close();*/

                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string          q          = "select * from user.staff where staff_id='" + textboxUsername.Text + "' and staff_password='******';";
                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;
                    MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                    if (MyReader2.Read())
                    {
                        MessageBox.Show("You have succesfully logged in");
                        StaffWindow objStaffWindow = new StaffWindow();
                        objStaffWindow.Show();
                        objStaffWindow.loginAsStaff.Text = textboxUsername.Text;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password do not match");
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            else if (combobox.SelectedItem.Equals("Doctor"))
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string          q          = "select * from user.doctor where id='" + textboxUsername.Text + "' and password='******';";
                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;
                    MyReader2 = MyCommand2.ExecuteReader();
                    if (MyReader2.Read())
                    {
                        DoctorWindow objDoctorWindow = new DoctorWindow();
                        objDoctorWindow.loginAsDoctor.Text = textboxUsername.Text;
                        objDoctorWindow.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password do not match");
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (combobox.SelectedItem.Equals("Adminstrator"))
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string          q          = "select * from user.admin where username='******' and password='******';";
                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;
                    MyReader2 = MyCommand2.ExecuteReader();
                    if (MyReader2.Read())
                    {
                        MessageBox.Show("You have succesfully logged in");
                        AdminWindow objAdminWindow = new AdminWindow();
                        objAdminWindow.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password do not match");
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #2
0
        private void button31_Click(object sender, EventArgs e)
        {
            try
            {
                string MyConnection2 = "server=localhost;uid=root;pwd=;database=snacks";
                string Query = "insert into drinks(ProductName, Price) values('" + this.textBox1.Text + "','" + this.textBox4.Text + "');";
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                if (MessageBox.Show("Are you sure, or you want more to add?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {

                }
                else
                {
                    return;
                }


                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();       
                MessageBox.Show("Save Data");
                while (MyReader2.Read())
                {
                    button5.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString())));
                    button4.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button21.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button27.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button2.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button9.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button13.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button16.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button17.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button3.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button1.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button26.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button6.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button7.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button25.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button10.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button11.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button8.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button28.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button14.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button15.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button12.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button29.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button18.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button19.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button20.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button30.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button22.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button23.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                    button24.Text = ((MyReader2["ProductName"].ToString() + " " + MyReader2["Price"].ToString()));
                }

                MyConn2.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        public void refresh()
        {
            string sql = " SELECT *  FROM bot WHERE chatid='" + client_id2 + "' ";


            MySqlConnection conn = new MySqlConnection(strconn);
            MySqlCommand    cmd  = new MySqlCommand(sql, conn);

            conn.Open();

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                namela     = reader.GetString("firstname");
                lnamela    = reader.GetString("lastname");
                mobla      = reader.GetString("mobile");
                amountla   = reader.GetString("amont");
                amount     = Convert.ToInt32(reader.GetString("amont"));
                accla      = reader.GetString("vip");
                nightla    = reader.GetString("night");
                smsla      = reader.GetString("sms");
                simpla     = reader.GetString("simp");
                datela     = reader.GetString("date");
                clientidla = reader.GetString("chatid");
            }
            conn.Close();



            string sql2 = " SELECT *  FROM const WHERE name='cost' ";


            MySqlConnection conn2 = new MySqlConnection(strconn);
            MySqlCommand    cmd2  = new MySqlCommand(sql2, conn2);

            conn2.Open();

            MySqlDataReader reader2 = cmd2.ExecuteReader();

            while (reader2.Read())
            {
                cost     = Convert.ToInt32(reader2.GetString("amontwin"));
                sympcost = Convert.ToInt32(reader2.GetString("symp"));
                if (smsla == "1")
                {
                    smscost = Convert.ToInt32(reader2.GetString("sms"));
                }
                else
                {
                    smscost = 0;
                }
            }
            conn2.Close();



            string          sql5  = "SELECT * FROM orderc where clientid='" + clientidla + "' and send='no' and pay='yes' and block='1' and blocksee='0' Order By date DESC LIMIT 4";
            MySqlConnection conn5 = new MySqlConnection(strconn);
            MySqlCommand    cmd5  = new MySqlCommand(sql5, conn5);

            conn5.Open();

            MySqlDataReader reader5 = cmd5.ExecuteReader();

            while (reader5.Read())
            {
                MessageBox.Show("سفارش شماره '" + reader5.GetString("id") + "' به توضیح '" + reader5.GetString("des") + "' به دلیل '" + reader5.GetString("blocktext") + "' حذف شده است . لطفا دوباره با توجه به توضیحات ارسال کنید.", "فایل ناقص", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading, false);

                string query = "UPDATE  orderc SET blocksee='1' WHERE id='" + reader5.GetString("id") + "'";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2 = new MySqlConnection(strconn);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand2 = new MySqlCommand(query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.

                while (MyReader2.Read())
                {
                }
                MyConn2.Close();
            }
            conn5.Close();



            name_la.Text   = namela;
            lname_la.Text  = lnamela;
            mob_la.Text    = mobla;
            amount_la.Text = amountla;


            if (accla == "0")
            {
                acc_la.Text = "عادی";
            }
            else
            {
                acc_la.Text = "ویژه";
            }


            if (nightla == "0")
            {
                night_la.Text = "غیر فعال";
            }
            else
            {
                night_la.Text = "فعال";
            }


            if (smsla == "0")
            {
                sms_la.Text = "غیر فعال";
            }
            else
            {
                sms_la.Text = "فعال";
            }


            if (simpla == "0")
            {
                simp_la.Text         = "غیر فعال";
                radioButton8.Enabled = false;
            }
            else
            {
                simp_la.Text         = "فعال";
                radioButton8.Enabled = true;
            }

            DateTime d = DateTime.Parse(datela);

            PersianCalendar pc = new PersianCalendar();

            date_la.Text = string.Format("{0}/{1}/{2}   {3}:{4}:{5}", pc.GetYear(d), pc.GetMonth(d), pc.GetDayOfMonth(d), pc.GetHour(d), pc.GetMinute(d), pc.GetSecond(d));

            clientid_la.Text = clientidla;


            var dateNow = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time"));



            var date = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day,
                                    dateNow.Hour, dateNow.Minute, dateNow.Second);



            //  string query7 = "UPDATE  bot SET date='@date' WHERE chatid='" + client_id2 + "'";
            //
            //  //This is  MySqlConnection here i have created the object and pass my connection string.
            //  MySqlConnection MyConn7 = new MySqlConnection(strconn);
            //  //This is command class which will handle the query and connection object.
            //  MySqlCommand MyCommand7 = new MySqlCommand(query7, MyConn7);
            //  MySqlDataReader MyReader7;
            //  MyConn7.Open();
            //  MyReader7 = MyCommand7.ExecuteReader();     // Here our query will be executed and data saved into the database.
            //
            //  while (MyReader7.Read())
            //  {
            //  }
            //  MyConn7.Close();
            //
        }
Example #4
0
        private void Button4_Click_1(object sender, EventArgs e)
        {
            this.Enabled = false;

            progressBar2.Enabled = true;
            progressBar3.Enabled = true;
            progressBar4.Enabled = true;
            progressBar5.Enabled = true;
            if (bank_ra.Checked)
            {
                MessageBox.Show("در این نسخه امکان پرداخت بانکی وجود ندارد");
            }
            else
            {
                refresh();



                string sql = " SELECT *  FROM bot WHERE chatid='" + client_id2 + "' ";


                MySqlConnection conn = new MySqlConnection(strconn);
                MySqlCommand    cmd  = new MySqlCommand(sql, conn);

                conn.Open();

                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    vip      = reader.GetString("vip");
                    night    = reader.GetString("night");
                    rate     = Convert.ToDouble(reader.GetString("rate"));
                    ratesimp = Convert.ToDouble(reader.GetString("ratesimp"));
                }
                conn.Close();



                var dateNow2 = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time"));



                var date = new DateTime(dateNow2.Year, dateNow2.Month, dateNow2.Day,
                                        dateNow2.Hour, dateNow2.Minute, dateNow2.Second);



                if (clas == true)
                {
                    MySqlCommand command;



                    if (amount < (cost * rate))
                    {
                        MessageBox.Show("موجودی کافی نیست");
                    }
                    else
                    {
                        String insertQuery = "insert into orderc(type,class,blocktext,clientid,des,date,halghe,voice,photo,dhalghe,progress,file,Mac,User,errordes,status,pay,despay,Vip,Night) values(4,1,'',@clientid,@dess,@date,@halghe,'','','','','','','','','','yes','موجودی',@vip,@night)";

                        conn.Open();

                        command = new MySqlCommand(insertQuery, conn);

                        command.Parameters.Add("@clientid", MySqlDbType.Int16, 11);
                        command.Parameters.Add("@dess", MySqlDbType.VarChar, 128);
                        command.Parameters.Add("@date", MySqlDbType.DateTime);

                        command.Parameters.Add("@halghe", MySqlDbType.Int16, 11);
                        command.Parameters.Add("@dhalghe", MySqlDbType.VarChar, 128);
                        command.Parameters.Add("@vip", MySqlDbType.Int16, 11);
                        command.Parameters.Add("@night", MySqlDbType.Int16, 11);

                        command.Parameters["@clientid"].Value = client_id2;
                        command.Parameters["@dess"].Value     = richTextBox1.Text;
                        command.Parameters["@date"].Value     = date;

                        command.Parameters["@halghe"].Value  = halghe;
                        command.Parameters["@dhalghe"].Value = textBox8.Text;
                        command.Parameters["@vip"].Value     = vip;
                        command.Parameters["@night"].Value   = night;

                        if (command.ExecuteNonQuery() == 1)
                        {
                            getlastid();



                            if (pictureBox1.Image != null)
                            {
                                WebClient client = new WebClient();
                                client.Credentials = new NetworkCredential("saiona", "saiona123");
                                var uri = new System.Uri(@"ftp://golden-art.ir/public_html/Images/" + id + namepic1 + ".jpg", UriKind.Absolute);
                                client.UploadProgressChanged += new UploadProgressChangedEventHandler(Progresss1);
                                client.UploadFileAsync(uri, imgadd);
                            }

                            if (pictureBox2.Image != null)
                            {
                                WebClient client2 = new WebClient();
                                client2.Credentials = new NetworkCredential("saiona", "saiona123");
                                var uri2 = new System.Uri(@"ftp://golden-art.ir/public_html/Images/" + id + namepic2 + ".jpg", UriKind.Absolute);
                                client2.UploadProgressChanged += new UploadProgressChangedEventHandler(Progresss2);
                                client2.UploadFileAsync(uri2, imgadd2);
                            }



                            if (pictureBox3.Image != null)
                            {
                                WebClient client3 = new WebClient();
                                client3.Credentials = new NetworkCredential("saiona", "saiona123");
                                var uri3 = new System.Uri(@"ftp://golden-art.ir/public_html/Images/" + id + namepic3 + ".jpg", UriKind.Absolute);
                                client3.UploadProgressChanged += new UploadProgressChangedEventHandler(Progresss3);
                                client3.UploadFileAsync(uri3, imgadd3);
                            }


                            if (pictureBox4.Image != null)
                            {
                                WebClient client4 = new WebClient();
                                client4.Credentials = new NetworkCredential("saiona", "saiona123");
                                var uri4 = new System.Uri(@"ftp://golden-art.ir/public_html/Images/" + id + namepic4 + ".jpg", UriKind.Absolute);
                                client4.UploadProgressChanged += new UploadProgressChangedEventHandler(Progresss4);
                                client4.UploadFileAsync(uri4, imgadd4);
                            }



                            label23.Visible = true;
                        }

                        conn.Close();



                        if (pictureBox1.Image == null)
                        {
                            names1 = null;
                        }
                        else
                        {
                            names1 = (id + namepic1 + ".jpg");
                        }

                        if (pictureBox2.Image == null)
                        {
                            names2 = null;
                        }
                        else
                        {
                            names2 = (id + namepic2 + ".jpg");
                        }

                        if (pictureBox3.Image == null)
                        {
                            names3 = null;
                        }
                        else
                        {
                            names3 = (id + namepic3 + ".jpg");
                        }

                        if (pictureBox4.Image == null)
                        {
                            names4 = null;
                        }
                        else
                        {
                            names4 = (id + namepic4 + ".jpg");
                        }



                        string query2 = "UPDATE  orderc SET lphoto='" + names1 + "',lphoto2='" + names2 + "',lphoto3='" + names3 + "',lphoto4='" + names4 + "'  WHERE id='" + id + "'";

                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn3 = new MySqlConnection(strconn);
                        //This is command class which will handle the query and connection object.
                        MySqlCommand    MyCommand3 = new MySqlCommand(query2, MyConn3);
                        MySqlDataReader MyReader3;
                        MyConn3.Open();
                        MyReader3 = MyCommand3.ExecuteReader();     // Here our query will be executed and data saved into the database.

                        while (MyReader3.Read())
                        {
                        }
                        MyConn3.Close();



                        string query = "UPDATE  bot SET amont='" + (amount - ((cost * rate) + smscost)) + "' WHERE chatid='" + client_id2 + "'";

                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn2 = new MySqlConnection(strconn);
                        //This is command class which will handle the query and connection object.
                        MySqlCommand    MyCommand2 = new MySqlCommand(query, MyConn2);
                        MySqlDataReader MyReader2;
                        MyConn2.Open();
                        MyReader2 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database.

                        while (MyReader2.Read())
                        {
                        }
                        MyConn2.Close();

                        if (smsla == "1")
                        {
                            smssend(mobla, id.ToString(), "order");
                        }


                        radioButton1.Checked = true;
                        radioButton2.Checked = false;
                        radioButton3.Checked = false;
                        radioButton4.Checked = false;
                        radioButton5.Checked = false;
                        radioButton6.Checked = false;
                        radioButton7.Checked = false;
                        textBox8.Text        = "";
                        richTextBox1.Text    = "";
                    }
                }
                else
                {
                    MySqlCommand command;



                    if (amount < (sympcost * ratesimp))
                    {
                        MessageBox.Show("موجودی کافی نیست");
                    }
                    else
                    {
                        String insertQuery = "insert into orderc(type,class,blocktext,clientid,des,date,voice,photo,dhalghe,progress,file,Mac,User,errordes,status,pay,despay,Vip,Night) values(4,2,'',@clientid,@dess,@date,'','','','','','','','','','yes','موجودی',@vip,@night)";

                        conn.Open();

                        command = new MySqlCommand(insertQuery, conn);

                        command.Parameters.Add("@clientid", MySqlDbType.Int16, 11);
                        command.Parameters.Add("@dess", MySqlDbType.VarChar, 128);
                        command.Parameters.Add("@date", MySqlDbType.DateTime);

                        command.Parameters.Add("@vip", MySqlDbType.Int16, 11);
                        command.Parameters.Add("@night", MySqlDbType.Int16, 11);

                        command.Parameters["@clientid"].Value = client_id2;
                        command.Parameters["@dess"].Value     = richTextBox1.Text;
                        command.Parameters["@date"].Value     = date;

                        command.Parameters["@vip"].Value   = vip;
                        command.Parameters["@night"].Value = night;

                        if (command.ExecuteNonQuery() == 1)
                        {
                            label23.Visible = true;
                        }

                        conn.Close();



                        string query = "UPDATE  bot SET amont='" + (amount - ((sympcost * ratesimp) + smscost)) + "' WHERE chatid='" + client_id2 + "'";

                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn2 = new MySqlConnection(strconn);
                        //This is command class which will handle the query and connection object.
                        MySqlCommand    MyCommand2 = new MySqlCommand(query, MyConn2);
                        MySqlDataReader MyReader2;
                        MyConn2.Open();
                        MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.

                        while (MyReader2.Read())
                        {
                        }
                        MyConn2.Close();



                        if (smsla == "1")
                        {
                            smssend(mobla, id.ToString(), "order");
                        }


                        radioButton1.Checked = true;
                        radioButton2.Checked = false;
                        radioButton3.Checked = false;
                        radioButton4.Checked = false;
                        radioButton5.Checked = false;
                        radioButton6.Checked = false;
                        radioButton7.Checked = false;
                        textBox8.Text        = "";
                        richTextBox1.Text    = "";
                        pictureBox1.Image    = null;
                        pictureBox2.Image    = null;
                        pictureBox3.Image    = null;
                        pictureBox4.Image    = null;
                        img  = null;
                        img2 = null;
                        img3 = null;
                        img4 = null;
                    }
                }
                getid();

                refresh();
            }
            if (pictureBox1.Image == null && pictureBox2.Image == null && pictureBox3.Image == null && pictureBox4.Image == null)
            {
                this.Enabled = true;
            }
        }
Example #5
0
        protected void viewdata_Click(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gvbind();
            }
            try
            {
                string con = "server=localhost;user id=root;database=mts";

                string insertQuery = "select * from propertydata where id=@id";

                MySqlConnection con2 = new MySqlConnection(con);

                MySqlCommand Mycon2 = new MySqlCommand(insertQuery, con2);
                Mycon2.Parameters.AddWithValue("@id", Property_Number.Value);

                //Mycon2.Parameters["@id"].Value = newid;

                MySqlDataReader MyReader2;
                con2.Open();

                MyReader2 = Mycon2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                if (MyReader2.Read())
                {
                    string newmycon = "server=localhost;user id=root;database=mts";

                    string myquery = "SELECT * FROM propertydata where id='" + Property_Number.Value + "'";

                    MySqlConnection newcon = new MySqlConnection(newmycon);

                    newcon.Open();

                    MySqlCommand cmd = new MySqlCommand();

                    cmd.CommandText = myquery;
                    cmd.Connection  = newcon;
                    MySqlDataAdapter da = new MySqlDataAdapter();
                    //Mycon2.Connection = con2;
                    da.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    GridView1.DataSource = ds;
                    GridView1.DataBind();
                    newcon.Close();
                    //if (ds.Tables[0].Rows.Count > 0)
                    //{
                    //    GridView1.DataSource = ds;
                    //    GridView1.DataBind();
                    //}
                    //else
                    //{
                    //    ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
                    //    GridView1.DataSource = ds;
                    //    GridView1.DataBind();
                    //    int columncount = GridView1.Rows[0].Cells.Count;
                    //    GridView1.Rows[0].Cells.Clear();
                    //    GridView1.Rows[0].Cells.Add(new TableCell());
                    //    GridView1.Rows[0].Cells[0].ColumnSpan = columncount;
                    //    GridView1.Rows[0].Cells[0].Text = "No Records Found";
                    //}
                    view_Data_Message.Text = "Retrieve Data Successful";
                }
                else
                {
                    view_Data_Message.Text = "Retrieve Data Failed.";
                }
                con2.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            string s = textBox1.Text;
            int    l = 0;

            try
            {
                int count = 0;
                //This is my connection string i have assigned the database file address path
                string MyConnection2 = "datasource=localhost;port=3306;username=root;password=aman";
                //This is my insert query in which i am taking input from the user through windows forms
                string pleasechalja = "Select automobile.calc_salary('" + s + "');";// and Password = '******')";
                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand2 = new MySqlCommand(pleasechalja, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                //MessageBox.Show("Save Data");
                while (MyReader2.Read())
                {
                    l = MyReader2.GetInt32(0);
                }
                MessageBox.Show("Salary = " + l.ToString());

                //textBox2.Text = count.ToString();
                MyConn2.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }



            string si = textBox1.Text;
            int    li = 0;

            try
            {
                int count = 0;
                //This is my connection string i have assigned the database file address path
                string MyConnection2 = "datasource=localhost;port=3306;username=root;password=aman";
                //This is my insert query in which i am taking input from the user through windows forms
                string pleasechalja = "Select automobile.calc_sales('" + si + "');";// and Password = '******')";
                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand2 = new MySqlCommand(pleasechalja, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                //MessageBox.Show("Save Data");
                while (MyReader2.Read())
                {
                    li = MyReader2.GetInt32(0);
                }
                MessageBox.Show("Sales = " + li.ToString());

                //textBox2.Text = count.ToString();
                MyConn2.Close();
                int ans = li - l;
                MessageBox.Show("Profit = " + ans.ToString());
                Form12 ob = new Form12();
                this.Hide();
                ob.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }