Ejemplo n.º 1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     //  try
     //  {
     if (comboBox4.Text == "أختر رقم الحبر....." || comboBox1.Text == "أختر نوع الجهاز...." || comboBox2.Text == "أختر أسم الجهاز....")
     {
         //  MessageBox.Show("هنالك حقول قارغة", "....", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
         Msg_Info.ShowMsg("هنالك حقول قارغة يجب تعبئة جميع الحقول", "حقول فارغة");
         return;
     }
 }
Ejemplo n.º 2
0
        private void Update_Values()
        {
            int Inks_V      = 0;
            int IPrinters_V = 0;
            int Hardware_V  = 0;

            if (Inks.Checked == true)
            {
                Inks_V = 1;
            }
            if (Printers.Checked == true)
            {
                IPrinters_V = 1;
            }
            if (Hardware.Checked == true)
            {
                Hardware_V = 1;
            }

            SqlStatement = "update Company set [Company_name] = @Company_name, [Phone] = @Phone, [Location] = @Location,[Ink_Deal] = @Ink_Deal ,[Printer_Deal] = @Printer_Deal, [Hardware_Deal] = @Hardware_Deal where [ID] = @ID";
            command      = new SqlCommand(SqlStatement, con.conn);
            command.Parameters.AddWithValue("@Company_name", Company_name.Text);
            command.Parameters.AddWithValue("@Phone", Phone.Text);
            command.Parameters.AddWithValue("@Location", Location.Text);
            command.Parameters.AddWithValue("@Ink_Deal", Inks_V);
            command.Parameters.AddWithValue("@Printer_Deal", IPrinters_V);
            command.Parameters.AddWithValue("@Hardware_Deal", Hardware_V);
            command.Parameters.AddWithValue("@ID", ID);
            sqladapter = new SqlDataAdapter();
            sqladapter.InsertCommand = command;
            sqladapter.InsertCommand.ExecuteNonQuery();
            command.Dispose();

            Msg_Info = new MsgBox_Info();
            Msg_Info.ShowMsg("تمت عملية الحفظ بنجاح", "تم");
        }
Ejemplo n.º 3
0
        private void Button8_Click(object sender, EventArgs e)
        {
            try
            {
                con.open();
                if (comboBox1.Text == "" || textBox5.Text == "" || comboBox3.Text == "")
                {
                    //  MessageBox.Show("هنالك حقول قارغة", "....", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
                    Msg_El = new Form1();
                    Msg_El.Show("هنالك حقول فارغة يجب تعبئة جميع الحقول");
                    con.close();
                    return;
                }



                Printer_Type = comboBox1.Text;
                Print_Name   = comboBox2.Text;
                Company_Name = textBox5.Text;
                Usages       = comboBox3.Text;
                Note         = textBox2.Text;
                Colored      = 0;
                Scan         = 0;
                Ethernet     = 0;
                Copy         = 0;
                print        = 0;
                if (Colored_Check.Checked == true)
                {
                    Colored = 1;
                }
                if (Scan_Check.Checked == true)
                {
                    Scan = 1;
                }
                if (Ethernet_Check.Checked == true)
                {
                    Ethernet = 1;
                }
                if (Copy_Check.Checked == true)
                {
                    Copy = 1;
                }
                if (Print_Check.Checked == true)
                {
                    print = 1;
                }



                //Update Printer table
                SqlStatement = "update printers set [Print_Type] = @Print_Type, [Company_name] = @Company_name, [Usages] = @Usages,[Note] = @Note ,[Scan] = @Scan, [Colored] = @Colored, [Ethernet] = @Ethernet, [Copy]= @Copy, [Print] = @Print where [Print_Name] = @Printer_Name";
                command      = new SqlCommand(SqlStatement, con.conn);
                command.Parameters.AddWithValue("@Printer_Name", Print_Name);
                command.Parameters.AddWithValue("@Print_Type", Printer_Type);
                command.Parameters.AddWithValue("@Company_name", Company_Name);
                command.Parameters.AddWithValue("@Usages", Usages);
                command.Parameters.AddWithValue("@Note", Note);
                command.Parameters.AddWithValue("@Scan", Scan);
                command.Parameters.AddWithValue("@Colored", Colored);
                command.Parameters.AddWithValue("@Ethernet", Ethernet);
                command.Parameters.AddWithValue("@Copy", Copy);
                command.Parameters.AddWithValue("@Print", print);
                sqladapter.InsertCommand = command;
                sqladapter.InsertCommand.ExecuteNonQuery();
                command.Dispose();


                //Delete Old Items from Inks_Store tables
                SqlStatement             = "Delete from Inks_Store where [Printer_Name]='" + Print_Name + "'";
                command                  = new SqlCommand(SqlStatement, con.conn);
                sqladapter.InsertCommand = command;
                sqladapter.InsertCommand.ExecuteNonQuery();
                command.Dispose();


                //Add New Items to inks table
                foreach (DataGridViewRow g1 in dataGridView1.Rows)
                {
                    if (!string.IsNullOrEmpty(g1.Cells[0].Value as string))
                    {
                        command = new SqlCommand("insert into Inks_Store([Printer_Name],[Ink_Number],[Color]) values ('" + comboBox2.Text + "','" + g1.Cells[0].Value + "',N'" + g1.Cells[1].Value + "')", con.conn);
                        command.ExecuteNonQuery();
                    }
                }



                con.close();
                Msg_Info = new MsgBox_Info();
                Msg_Info.ShowMsg("تمت عملية الحفظ بنجاح", "تم");
            }
            catch
            {
                Msg_E = new MsgBox_Error();
                Msg_E.ShowMsg("حدث خطأ أثناء عملية التحديث للبيانات", "خطأ");
                con.close();
            }
        }
Ejemplo n.º 4
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            Form1 Msg;

            try
            {
                if (comboBox1.Text == "" || textBox1.Text == "" || textBox5.Text == "" || comboBox3.Text == "")
                {
                    //  MessageBox.Show(Cursor.Position.X.ToString());
                    //Msg_Info.ShowMsg("هنالك حقول قارغة ,يجب تعبئة كافة الحقول", "حقول فارغة");
                    Msg = new Form1();
                    Msg.Show("هنالك حقول قارغة ,يجب تعبئة كافة الحقول");
                    return;
                }


                con = new Connection();
                con.open();
                Exist = false;
                // TO Check If Value exists
                SqlStatement = "select [Print_Name] from Printers";
                command      = new SqlCommand(SqlStatement, con.conn);
                Read         = command.ExecuteReader();
                while (Read.Read())
                {
                    if (Read[0].ToString().Trim().ToLower() == textBox1.Text.Trim().ToLower())
                    {
                        Exist    = true;
                        Msg_Info = new MsgBox_Info();
                        Msg_Info.ShowMsg("....أسم الجهاز موجود بالفعل ", "أسم الجهاز مدخل سابقاً");
                        command.Dispose();
                        con.close();
                        return;
                    }
                }



                Printer_Type = comboBox1.Text;
                Printer_Name = textBox1.Text;
                Company_Name = textBox5.Text;
                Usages       = comboBox3.Text;
                Note         = textBox2.Text;
                Colored      = 0;
                Scan         = 0;
                Ethernet     = 0;
                Copy         = 0;
                print        = 0;
                if (Colored_Check.Checked == true)
                {
                    Colored = 1;
                }
                if (Scan_Check.Checked == true)
                {
                    Scan = 1;
                }
                if (Ethernet_Check.Checked == true)
                {
                    Ethernet = 1;
                }
                if (Copy_Check.Checked == true)
                {
                    Copy = 1;
                }
                if (Print_Check.Checked == true)
                {
                    print = 1;
                }

                SqlStatement = "insert into printers([Print_Type],[Print_Name],[Company_name],[Usages],[Scan],[Colored],[Ethernet],[Copy],[Print],[Note]) values (N'" + Printer_Type + "','" + Printer_Name + "','" + Company_Name + "','" + Usages + "','" + Scan + "','" + Colored + "','" + Ethernet + "','" + Copy + "','" + print + "',N'" + Note + "')";

                command = new SqlCommand(SqlStatement, con.conn);
                sqladapter.InsertCommand = command;
                sqladapter.InsertCommand.ExecuteNonQuery();
                command.Dispose();



                foreach (DataGridViewRow g1 in dataGridView1.Rows)

                {
                    if (!string.IsNullOrEmpty(g1.Cells[0].Value as string))
                    {
                        command = new SqlCommand("insert into Inks_Store([Printer_Name],[Ink_Number],[Color]) values ('" + textBox1.Text + "','" + g1.Cells[0].Value + "',N'" + g1.Cells[1].Value + "')", con.conn);
                        command.ExecuteNonQuery();
                    }
                }

                con.close();
                Msg_Info = new MsgBox_Info();
                Msg_Info.ShowMsg("تمت عملية الحفظ بنجاح", "تم");
            }
            catch
            {
                Msg_Er = new MsgBox_Error();
                Msg_Er.ShowMsg("حدث خطأ أثناء تنقيذ عملية الادخال", "خطأ");
                con.close();
            }
        }
Ejemplo n.º 5
0
        private void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.Company_name.Text == "" || this.Phone.Text == "" || this.Location.Text == "")
                {
                    //  MessageBox.Show("هنالك حقول قارغة", "....", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
                    Msg_El = new Form1();
                    Msg_El.Show("هنالك حقول قارغة يجب تعبئة كافة الحقول");
                    return;
                }



                con.open();

                if (Selected_value == true)
                {
                    Update_Values();
                }
                else
                {
                    int Inks_value     = 0;
                    int Printers_value = 0;
                    int Hardware_value = 0;

                    if (Inks.Checked == true)
                    {
                        Inks_value = 1;
                    }
                    if (Printers.Checked == true)
                    {
                        Printers_value = 1;
                    }
                    if (Hardware.Checked == true)
                    {
                        Hardware_value = 1;
                    }



                    //Insert new Items to Companies tables

                    SqlStatement             = "insert into Company([Company_Name],[Phone],[Location],[Ink_Deal],[Printer_Deal],[Hardware_Deal]) values (N'" + this.Company_name.Text + "','" + this.Phone.Text + "',N'" + this.Location.Text + "','" + Inks_value + "','" + Printers_value + "','" + Hardware_value + "')";
                    command                  = new SqlCommand(SqlStatement, con.conn);
                    sqladapter               = new SqlDataAdapter();
                    sqladapter.InsertCommand = command;
                    sqladapter.InsertCommand.ExecuteNonQuery();
                    command.Dispose();



                    Msg_Info = new MsgBox_Info();
                    Msg_Info.ShowMsg("تمت عملية الحفظ بنجاح", "تم");
                }

                con.close();
                items_load();
            }
            catch
            {
                Msg_E = new MsgBox_Error();
                Msg_E.ShowMsg("حدث خطأ أثناء عملية التحديث للبيانات", "خطأ");
                con.close();
            }
        }