Ejemplo n.º 1
0
        private void add_btn_Click(object sender, EventArgs e)
        {
            if (state == "add")
            {
                byte[] byteimage = null;

                // first convert the image to binary input
                MemoryStream memoryStream = new MemoryStream();
                // we put the image in the stream created
                pictureBox1.Image.Save(memoryStream, pictureBox1.Image.RawFormat);
                byteimage = memoryStream.ToArray();


                // now we pass the parameters to the add_cloth class
                // we put the compo as selected value cuz it is the primary
                // we want to pas, nit the display member
                try
                {
                    clo.Add_Cloth(Convert.ToInt32(cmbCat.SelectedValue), id.Text
                                  , desc.Text, Convert.ToInt32(quantity.Text), price.Text, Convert.ToInt32(Subcombo.SelectedValue),
                                  byteimage);

                    MessageBox.Show("تمت الاضافة بنجاح", "عملية الإضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString() + "يرجى إدخال البيانات بشكل صحيح", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                byte[] byteimage = null;

                // first convert the image to binary input
                MemoryStream memoryStream = new MemoryStream();
                // we put the image in the stream created
                pictureBox1.Image.Save(memoryStream, pictureBox1.Image.RawFormat);
                byteimage = memoryStream.ToArray();


                // now we pass the parameters to the add_cloth class
                // we put the compo as selected value cuz it is the primary
                // we want to pas, nit the display member
                try
                {
                    clo.UpdateClothes(Convert.ToInt32(cmbCat.SelectedValue), id.Text
                                      , desc.Text, Convert.ToInt32(quantity.Text), price.Text, Convert.ToInt32(Subcombo.SelectedValue),
                                      byteimage);

                    MessageBox.Show("تم التحديث بنجاح", "عملية التحديث", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("يرجى إدخال البيانات بشكل صحيح", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            // this is for updatin the Datagrid even if the form is not lcosed
            ShowAllClothes.getShowAllClothes_Form().dataGridView1.DataSource = clo.ShowAll();
            ShowAllClothes.getShowAllClothes_Form().dataGridView1.Columns[6].Visible = false;
        }
Ejemplo n.º 2
0
 // this mehtod is to use the current main or create a new one if it = null
 // this method for getting the intialized main in the constructor, better to get a variable using get method
 public static ShowAllClothes getShowAllClothes_Form()
 {
     if (main == null)
     {
         main             = new ShowAllClothes();
         main.FormClosed += new FormClosedEventHandler(main_closed);
     }
     return(main);
 }
Ejemplo n.º 3
0
 public ShowAllClothes()
 {
     InitializeComponent();
     // this is for intializing the main to this
     if (main == null)
     {
         main = this;
     }
     this.dataGridView1.DataSource         = clo.ShowAll();
     this.dataGridView1.Columns[6].Visible = false;
 }
Ejemplo n.º 4
0
 private void عرضبضائعهذاالموردToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         PL.ShowAllClothes shoclo = new ShowAllClothes();
         shoclo.SearchState     = "NotDefault";
         shoclo.textSearch.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + "" + this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
         shoclo.ShowDialog();
         if (shoclo.closed)
         {
             this.dataGridView1.DataSource = cust.getAllSubb();
             // this is for hiding the id يعتمد على رتبته في الاجراء المخزن
             this.dataGridView1.Columns[0].Visible = false;
         }
     }
     catch
     {
         return;
     }
 }
Ejemplo n.º 5
0
        // this is for lcosing the static variable

        public static void main_closed(Object sender, FormClosedEventArgs e)
        {
            // we are making it nnull because we may deal with it in another for other rthanthe login  Form
            main = null;
        }