示例#1
0
 private void SunStoreDisconnectedModefrm_Load_1(object sender, EventArgs e)
 {
     LoadIDs();
     LoadData();
     ProductIDcbx.Hide();
     ProductsIDlbl.Hide();
     ProductNametxt.Hide();
     ProductNamelbl.Hide();
     Pricetxt.Hide();
     Pricelbl.Hide();
     btn.Hide();
     btn.Text = "";
 }
示例#2
0
 private void Searchbtn_CheckedChanged_1(object sender, EventArgs e)
 {
     if (Searchbtn.Checked == true)
     {
         ProductIDcbx.Hide();
         ProductsIDlbl.Hide();
         ProductNametxt.Show();
         ProductNamelbl.Show();
         Pricetxt.Show();
         Pricelbl.Show();
         btn.Show();
         btn.Text = "Search";
     }
 }
示例#3
0
 private void DELradiobtn_CheckedChanged(object sender, EventArgs e)
 {
     if (DELradiobtn.Checked == true)
     {
         ProductIDcbx.Show();
         ProductsIDlbl.Show();
         ProductNametxt.Hide();
         ProductNamelbl.Hide();
         Pricetxt.Hide();
         Pricelbl.Hide();
         btn.Show();
         btn.Text = "Delete";
     }
 }
示例#4
0
 private void UPDradiobtn_CheckedChanged(object sender, EventArgs e)
 {
     if (UPDradiobtn.Checked == true)
     {
         ProductIDcbx.Show();
         ProductsIDlbl.Show();
         ProductNametxt.Show();
         ProductNamelbl.Show();
         Pricetxt.Show();
         Pricelbl.Show();
         btn.Show();
         btn.Text = "Edit";
     }
 }
示例#5
0
 private void ClearInputs()
 {
     BookNametxt.Clear();
     Pricetxt.Clear();
     Counttxt.Clear();
 }
示例#6
0
        private void SaveCourse_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
        {
            if (CourseNametxt.Tag == null)
            {
                if (CourseNametxt.Text == "")
                {
                    MessageBox.Show("Course Name Required");
                    CourseNametxt.Focus();
                }

                else if (Pricetxt.Text == "")
                {
                    MessageBox.Show("Price Required");
                    Pricetxt.Focus();
                }
                else if (decimal.Parse(Pricetxt.Text) < 100 || decimal.Parse(Pricetxt.Text) > 5000)
                {
                    MessageBox.Show("Price must be between 100 and 5000");
                    Pricetxt.Focus();
                    Pricetxt.SelectAll();
                }
                else if (PeriodTxt.Text == "")
                {
                    MessageBox.Show("Period Name Required");
                    PeriodTxt.Focus();
                }
                else if (CategoriesList.SelectedIndex == -1)
                {
                    MessageBox.Show("Select Category");
                    CategoriesList.Focus();
                }
                else
                {
                    SqlParameter[] p = new SqlParameter[5];
                    p[0]       = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
                    p[0].Value = CourseNametxt.Text;


                    p[1]       = new SqlParameter("@Price", SqlDbType.Float);
                    p[1].Value = float.Parse(Pricetxt.Text);

                    p[2]       = new SqlParameter("@Period", SqlDbType.NVarChar, 50);
                    p[2].Value = PeriodTxt.Text;

                    p[3]       = new SqlParameter("@CategoryID", SqlDbType.Int);
                    p[3].Value = int.Parse(CategoriesList.SelectedValue.ToString());

                    p[4]       = new SqlParameter("@Description", SqlDbType.NVarChar, 50);
                    p[4].Value = Descriptiontxt.Text;


                    DataAccess.InsUpDel("InsertCourse", p);

                    MessageBox.Show("Added");



                    CourseNametxt.Text           = string.Empty;
                    Pricetxt.Text                = "";
                    PeriodTxt.Text               = "";
                    CategoriesList.SelectedIndex = -1;
                    Descriptiontxt.Text          = "";

                    CourseNametxt.Focus();
                }
            }
            else
            {
                SqlParameter[] p = new SqlParameter[6];

                p[0]       = new SqlParameter("@CourseID", SqlDbType.Int);
                p[0].Value = int.Parse(CourseNametxt.Tag.ToString());

                p[1]       = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
                p[1].Value = CourseNametxt.Text;


                p[2]       = new SqlParameter("@Price", SqlDbType.Float);
                p[2].Value = float.Parse(Pricetxt.Text);

                p[3]       = new SqlParameter("@Period", SqlDbType.NVarChar, 50);
                p[3].Value = PeriodTxt.Text;

                p[4]       = new SqlParameter("@CategoryID", SqlDbType.Int);
                p[4].Value = int.Parse(CategoriesList.SelectedValue.ToString());

                p[5]       = new SqlParameter("@Description", SqlDbType.NVarChar, 50);
                p[5].Value = Descriptiontxt.Text;


                DataAccess.InsUpDel("EditCourse", p);

                MessageBox.Show("Edited");
            }
        }