اذهب إلى المحتوى

Abdu Mohamed

الأعضاء
  • المساهمات

    47
  • تاريخ الانضمام

  • تاريخ آخر زيارة

آخر الزوار

لوحة آخر الزوار معطلة ولن تظهر للأعضاء

إنجازات Abdu Mohamed

عضو مساهم

عضو مساهم (2/3)

11

السمعة بالموقع

  1. MySql.Data.MySqlClient.MySqlException HResult=0x80004005 Message=You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`,`Address`,`Photo` FROM `employee`' at line 1 Source=MySql.Data StackTrace: at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() at Transparent_Form.FormEmployee.LoadRecord() in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\FormEmployee.cs:line 90 at Transparent_Form.FormEmployee.FormEmployee_Load(Object sender, EventArgs e) in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\FormEmployee.cs:line 34 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) This exception was originally thrown at this call stack: [External Code] Transparent_Form.FormEmployee.LoadRecord() in FormEmployee.cs Transparent_Form.FormEmployee.FormEmployee_Load(object, System.EventArgs) in FormEmployee.cs [External Code] Line 90 cmd = new MySqlCommand("SELECT `Employee ID`,`EmpName`,`RegNO`,`Job_Title`,`Position`,`Hiring_Date`,`DeptId`,`Birthdate`,`Gender`,`Country' ,`Phone`,`Address`,`Photo` FROM `employee`", conn); dr = cmd.ExecuteReader(); while (dr.Read()) Line 34 private void FormEmployee_Load(object sender, EventArgs e) { LoadRecord(); dataGridView1.RowTemplate.Height = 25; }
  2. هناك خطا ما موجود لم اتمكن من معرفته public void LoadRecord() { dataGridView1.Rows.Clear(); conn.Open(); cmd = new MySqlCommand("SELECT `Employee ID`,`EmpName`,`RegNO`,`Job_Title`,`Position`,`Hiring_Date`,`DeptId`,`Birthdate`,`Gender`,`Country' ,`Phone`,`Address`,`Photo` FROM `employee`", conn); dr = cmd.ExecuteReader(); while (dr.Read()) { dataGridView1.Rows.Add(dataGridView1.Rows.Count + 1, dr["Employee ID"].ToString(), dr["EmpName"].ToString(), dr["RegNO"].ToString(), dr["Job_Title"].ToString(), dr["Position"].ToString(), dr["Hiring_Date"], dr["DeptId"].ToString(), dr["Birthdate"], dr.ToString(), dr["Gender"].ToString(), dr["Country"].ToString(), dr["Phone"].ToString(), dr["Address"].ToString(), dr["Photo"].ToString()); } dr.Close(); conn.Close(); } FormEmployee.cs
  3. لدي دومين مستضاف لدى HostGator والايميل استخدمت فيه 365 اوفيس يوجد مشكلة مع ايميل واحد تفشل الرسائل الصادرة مني دوما بالرغم من اني استقبل اي رسالة من قبلهم وعند السؤال كان التبرير هو وجود IP ضمن قوائم الحظر وقد الملفات ذات الصلة فكيف يمكن حل هذه المشكلة Undeliverable_ Emails .eml
  4. الان امكنني تنفيذ امر الادخال لكن يظهر خطا جديد حيث اني ارغب في حفظ المعلومات المدخلة الى جدول يمكننيمن خلاله تعديل او حذف اي معلومة وارفقت صورة الخطا الظاهر وارفقت البرمجة ايضا : 1- EmployeeInfoe : using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace Transparent_Form { public partial class EmployeeInfo : Form { FormEmployee Form; public EmployeeInfo() { InitializeComponent(); Form = new FormEmployee(this); } private void label4_Click(object sender, EventArgs e) { } public static void DisplayAndSearch(String query, DataGridView dgv) { string connection = "server=localhost; port=3306;username=root;password=;database=employeedb;Convert Zero Datetime=True"; string sql = query; MySqlConnection conn = new MySqlConnection(connection); MySqlCommand cmd = new MySqlCommand(query, conn); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); adp.SelectCommand = cmd; DataTable tbl = new DataTable(); adp.Fill(tbl); dgv.DataSource = tbl; } public void Display() { DisplayAndSearch("SELECT* From employee", dataGridView); } private void btn_NewEmployee_Click(object sender, EventArgs e) { Form.Clear(); Form.SaveInfo(); Form.ShowDialog(); } private void EmployeeInfo_Shown(object sender, EventArgs e) { Display(); } private void textBoxSearchEMP_TextChanged(object sender, EventArgs e) { // DbEmployee.DisplayAndSearch("SELECT * From employee_table WHERE Name LIKE '%"+textBoxSearchEMP.Text +"%'", dataGridView); } private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if(e.ColumnIndex == 0) { return; } if(e.ColumnIndex ==1) { // if(MessageBox.Show("Are you want to deletE EMPLOYEE ?", "Information", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes) { DbEmployee.DeleteEmployee(dataGridView.Rows[e.RowIndex].Cells[2].Value.ToString()); Display(); } return; } } private void textBoxSearchEMP_KeyPress(object sender, KeyPressEventArgs e) { } private void dataGridView_KeyDown(object sender, KeyEventArgs e) { } private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { } } } 2- FormEMPLOYEE using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; using System.IO; namespace Transparent_Form { public partial class FormEmployee : Form { private readonly EmployeeInfo _parent; string id, name, regNo, job_Title, position, hiring_Date, country, birthdate, gender, phone, address, deptid, @img; private void textBox_Position_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(textBox_Position.Text.Trim())) { errorProvider3.SetError(textBox_Position, "Position is Required"); return; } else { errorProvider1.SetError(textBox_Position, string.Empty); } } private void FormEmployee_Validated(object sender, EventArgs e) { } private void textBox_JopTitle_Validated(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox_JopTitle.Text.Trim())) { errorProvider2.SetError(textBox_JopTitle, "Title is Required"); return; } else { errorProvider1.SetError(textBox_JopTitle, string.Empty); } } private void textBox_EmpName_Validated(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox_EmpName.Text.Trim())) { errorProvider1.SetError(textBox_EmpName, "Name is Required"); return; } else { errorProvider1.SetError(textBox_EmpName, string.Empty); } } public FormEmployee(EmployeeInfo parent) { InitializeComponent(); _parent = parent; } public void UpdateInfo() { lbltext.Text = "Update Employee"; btn_Save.Text = "Update"; textBox_EmpName.Text = name; textBox_RegNo.Text = regNo; textBox_JopTitle.Text = job_Title; textBox_Position.Text = position; dateTimePicker_hd.Text = hiring_Date; dateTimePicker_bd.Text = birthdate; comboBox_Dept.Text = deptid; Cbox_Country.Text = country; textBox_phone.Text = phone; textBox_Address.Text = address; } public void SaveInfo() { lbltext.Text = "Add Employee"; lbltext.Text = "Save"; } public void Clear() { textBox_EmpName.Text = textBox_RegNo.Text = textBox_JopTitle.Text = textBox_Position.Text = dateTimePicker_bd.Text = dateTimePicker_hd.Text = textBox_Address.Text = textBox_phone.Text = Cbox_Country.Text = comboBox_Dept.Text = String.Empty; } private void panel2_Paint(object sender, PaintEventArgs e) { } private void button_upload_Click(object sender, EventArgs e) { // browse photo from your computer OpenFileDialog opf = new OpenFileDialog(); opf.Filter = "Select Photo(*.jpg;*.png;*.gif)|*.jpg;*.png;*.gif"; if (opf.ShowDialog() == DialogResult.OK) { pictureBox_employee.Image = Image.FromFile(opf.FileName); pictureBox_employee.ImageLocation = opf.FileName; pictureBox_employee.SizeMode = PictureBoxSizeMode.StretchImage; } } private void btn_Save_Click(object sender, EventArgs e) { string connection = "server=localhost; port=3306;username=root;password=;database=employeedb;Convert Zero Datetime=True"; //string ource=localhost; port=3306;username=root;password=;database=employeedb"; string query = "INSERT INTO employee(EmpName,RegNo,Job_Title,Position,Hiring_Date,Country,Birthdate,Gender,Phone,Address,Photo,DeptID) VALUES('" + this.textBox_EmpName.Text + "','" + this.textBox_RegNo.Text + "','" + this.textBox_JopTitle.Text + "','" + this.textBox_Position.Text + "','" + this.dateTimePicker_hd.Text + "','" + this.Cbox_Country.Text + "','" + this.dateTimePicker_bd.Text + "','" + this.comboBox_Gender.Text + "','" + this.textBox_phone.Text + "','" + this.textBox_Address.Text + "','" + this.pictureBox_employee.Image + "','" + this.comboBox_Dept.Text + "')"; MySqlConnection conn = new MySqlConnection(connection); MySqlCommand cmd = new MySqlCommand(query, conn); MySqlDataReader dr; conn.Open(); try { cmd.ExecuteNonQuery(); MessageBox.Show("UPDATED Succescfully", "Infrormation", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show("Employee is not UPDATED. \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } conn.Close(); } //r = cmd.ExecuteReader(); //essageBox.Show("Added Succescfully", "Infrormation", MessageBoxButtons.OK, MessageBoxIcon.Information); //onn.Close(); } }
  5. قمت بتحديد null لخانة id بحكم انها ستكون متغيرة لكل موظف مدخل ولن تتكرر
  6. عند الاضافة بالنقر على الزر لا يتم تنفيذ الامر وادخال بيانات النموذج في قاعدة البيانات ارجو المساعدة وقد تم اضافة الكلاس و الفورم والبرمجة لهما using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; using System.IO; namespace Transparent_Form { public partial class FormEmployee : Form { private readonly EmployeeInfo _parent; string id, name, regNo, job_Title, position, hiring_Date, country, birthdate, gender, phone, address, deptid, @img; public FormEmployee(EmployeeInfo parent) { InitializeComponent(); _parent = parent; } public void UpdateInfo() { lbltext.Text = "Update Employee"; btn_Save.Text = "Update"; textBox_EmpName.Text = name; textBox_RegNo.Text = regNo; textBox_JopTitle.Text = job_Title; textBox_Position.Text = position; textBox_Hiringdate.Text = hiring_Date; textBox_Birthdate.Text = birthdate; comboBox_Dept.Text = deptid; Cbox_Country.Text = country; textBox_phone.Text = phone; textBox_Address.Text = address; } public void SaveInfo() { lbltext.Text = "Add Employee"; lbltext.Text = "Save"; } public void Clear() { textBox_EmpName.Text = textBox_RegNo.Text = textBox_JopTitle.Text = textBox_Position.Text = textBox_Hiringdate.Text = textBox_Birthdate.Text = textBox_Address.Text = textBox_phone.Text = Cbox_Country.Text = comboBox_Dept.Text = String.Empty; } private void panel2_Paint(object sender, PaintEventArgs e) { } private void button_upload_Click(object sender, EventArgs e) { // browse photo from your computer OpenFileDialog opf = new OpenFileDialog(); opf.Filter = "Select Photo(*.jpg;*.png;*.gif)|*.jpg;*.png;*.gif"; if (opf.ShowDialog() == DialogResult.OK) { pictureBox_employee.Image = Image.FromFile(opf.FileName); pictureBox_employee.ImageLocation = opf.FileName; pictureBox_employee.SizeMode = PictureBoxSizeMode.StretchImage; } } private void btn_Save_Click(object sender, EventArgs e) { if (textBox_EmpName.Text.Trim().Length < 3) { MessageBox.Show("Employee name is Empty (< 3)."); return; } if (textBox_RegNo.Text.Trim().Length < 1) { MessageBox.Show("Employee reg is Empty (< 1)."); return; } if (textBox_JopTitle.Text.Trim().Length < 3) { MessageBox.Show("Employee title is Empty (< 3)."); return; } if (textBox_Position.Text.Trim().Length < 3) { MessageBox.Show("Employee position is Empty (< 3)."); return; } if (Cbox_Country.Text.Trim().Length < 3) { MessageBox.Show("Employee country is Empty (< 3)."); return; } if (comboBox_Dept.Text.Trim().Length < 3) { MessageBox.Show("Employee Department is Empty (< 3)."); return; } if (textBox_Birthdate.Text.Trim().Length < 3) { MessageBox.Show("Employee birthdate is Empty (< 3)."); return; } if (textBox_Hiringdate.Text.Trim().Length < 3) { MessageBox.Show("Employee hiringdate is Empty (< 3)."); return; } if (textBox_Address.Text.Trim().Length < 3) { MessageBox.Show("Employee Adress is Empty (< 3)."); return; } if (textBox_phone.Text.Trim().Length < 3) { MessageBox.Show("Employee phone is Empty (< 3)."); return; } if (pictureBox_employee.Image != null) ; return; { } } } } --- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Transparent_Form { public partial class EmployeeInfo : Form { FormEmployee Form; public EmployeeInfo() { InitializeComponent(); Form = new FormEmployee(this); } private void label4_Click(object sender, EventArgs e) { } public void Display() { DbEmployee.DisplayAndSearch("SELECT* From employee_table", dataGridView); } private void btn_NewEmployee_Click(object sender, EventArgs e) { Form.Clear(); Form.SaveInfo(); Form.ShowDialog(); } private void EmployeeInfo_Shown(object sender, EventArgs e) { Display(); } private void textBoxSearchEMP_TextChanged(object sender, EventArgs e) { // DbEmployee.DisplayAndSearch("SELECT* From employee_table WHERE Name LIKE '%"+textBoxSearchEMP.Text +"%'", dataGridView); } private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if(e.ColumnIndex == 0) { return; } if(e.ColumnIndex ==1) { if(MessageBox.Show("Are you want to deletE EMPLOYEE ?", "Information", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes) { DbEmployee.DeleteEmployee(dataGridView.Rows[e.RowIndex].Cells[2].Value.ToString()); Display(); } return; } } } } ---- using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; using System.IO; namespace Transparent_Form { internal class DbEmployee { public static MySqlConnection GetConnection() { string sql = "datasource= localhost; port=3306;username=root;password=;database=employeedb"; MySqlConnection con = new MySqlConnection(sql); try { con.Open(); } catch (MySqlException ex) { MessageBox.Show("MySQL Connection! \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return con; } public static void AddEmployee(Empl emp) // { string sql = "INSERT INTO employee_table VALUES(NULL,@EmpName,@RegNo,@Job_Tile,@Position,@Hiring_Date,@Country,@Birthdate,@Gender,@Phone,@Address,@Photo,@DeptId,NULL)"; MySqlConnection con = GetConnection(); MySqlCommand cmd = new MySqlCommand(sql, con); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.Add("@EmpName", MySqlDbType.VarChar).Value = emp.EmpName; cmd.Parameters.Add("@RegNo", MySqlDbType.VarChar).Value = emp.RegNo; cmd.Parameters.Add("@job_Title", MySqlDbType.VarChar).Value = emp.Job_Title; cmd.Parameters.Add("@position", MySqlDbType.VarChar).Value = emp.Position; cmd.Parameters.Add("@hiring_date", MySqlDbType.VarChar).Value = emp.Hiring_Date; cmd.Parameters.Add("@country", MySqlDbType.VarChar).Value = emp.Country; cmd.Parameters.Add("@birthdate", MySqlDbType.VarChar).Value = emp.Birthdate; cmd.Parameters.Add("@gender", MySqlDbType.VarChar).Value = emp.Gender; cmd.Parameters.Add("@phone", MySqlDbType.VarChar).Value = emp.Phone; cmd.Parameters.Add("@adrress", MySqlDbType.VarChar).Value = emp.Address; cmd.Parameters.Add("@img", MySqlDbType.Blob).Value = emp.Photo; cmd.Parameters.Add("@deptid", MySqlDbType.Blob).Value = emp.DeptId; try { cmd.ExecuteNonQuery(); MessageBox.Show("Added Succescfully", "Infrormation", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show("Employee is not inserted. \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); } public static void UpdateEmployee(Empl emp, string id) { string sql = "UPDATE employee_table SET Name =@EmpName,Reg No= @RegNo,Job title =@Job_Title ,Position =@position,Country =@country,Birthdate=@birthdate,Hiring Date=@hiring_date,gender=@gender ,Phone =@phone,Address=@adrress,photo=@img,DeptId=@deptid, WHERE ID - @EmpID'"; MySqlConnection con = GetConnection(); MySqlCommand cmd = new MySqlCommand(sql, con); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.Add("id", MySqlDbType.VarChar).Value = id; cmd.Parameters.Add("@EmpName", MySqlDbType.VarChar).Value = emp.EmpName; cmd.Parameters.Add("@RegNo", MySqlDbType.VarChar).Value = emp.RegNo; cmd.Parameters.Add("@Job_Title", MySqlDbType.VarChar).Value = emp.Job_Title; cmd.Parameters.Add("@position", MySqlDbType.VarChar).Value = emp.Position; cmd.Parameters.Add("@hiring_date", MySqlDbType.VarChar).Value = emp.Hiring_Date; cmd.Parameters.Add("@country", MySqlDbType.VarChar).Value = emp.Country; cmd.Parameters.Add("@birthdate", MySqlDbType.VarChar).Value = emp.Birthdate; cmd.Parameters.Add("@gender", MySqlDbType.VarChar).Value = emp.Gender; cmd.Parameters.Add("@phone", MySqlDbType.VarChar).Value = emp.Phone; cmd.Parameters.Add("@adrress", MySqlDbType.VarChar).Value = emp.Address; cmd.Parameters.Add("@img", MySqlDbType.Blob).Value = emp.Photo; try { cmd.ExecuteNonQuery(); MessageBox.Show("UPDATED Succescfully", "Infrormation", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show("Employee is not UPDATED. \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); } public static void DeleteEmployee(string id) { string sql = "DELETE FROM employee_table WHERE ID = @EmpID"; MySqlConnection con = GetConnection(); MySqlCommand cmd = new MySqlCommand(sql, con); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.Add("@EmpID", MySqlDbType.VarChar).Value = id; try { cmd.ExecuteNonQuery(); MessageBox.Show("DELETED Succescfully", "Infrormation", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show("Employee is not DELETED . \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); } public static void DisplayAndSearch(String query, DataGridView dgv) { string sql = query; MySqlConnection con = GetConnection(); MySqlCommand cmd = new MySqlCommand(sql, con); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); DataTable tbl = new DataTable(); adp.Fill(tbl); dgv.DataSource = tbl; con.Close(); } } } ---- using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using MySql.Data.MySqlClient; using System.IO; namespace Transparent_Form { internal class Empl { public string EmpName { get; set; } public string RegNo { get; set; } public string Job_Title { get; set; } public string Position { get; set; } public string Hiring_Date { get; set; } public string Country { get; set; } public string Birthdate { get; set; } public string Gender { get; set; } public string Phone { get; set; } public byte[] Photo { get; set; } public string Address { get; set; } public string DeptId { get; set; } public string V1 { get; } public Func<char[], string> Trim { get; } public string V2 { get; } public string V3 { get; } public string V4 { get; } public string V5 { get; } public string V6 { get; } public (string, string, string, string, Image InitialImage) P { get; } public Empl(string name, string regNo, string job_Title, string position, string hiring_Date, string country, string birthdate, string gender, string phone,string address,string deptid, byte[] img) { EmpName = name; RegNo = regNo; Job_Title = job_Title; Position = position; Hiring_Date = hiring_Date; Country = country; Birthdate = birthdate; this.Gender = gender; Phone = phone; Photo = img; Address = address; DeptId = deptid; } } } ------ FormEmployee.cs EmployeeInfo.cs Empl.cs DbEmployee.cs
  7. هذا نص الرسالة الواردة : System.FormatException HResult=0x80131537 Message=Input string was not in a correct format. Source=mscorlib StackTrace: at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s) at Transparent_Form.ManageEmployeeForm.button_update_Click(Object sender, EventArgs e) in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\ManageEmployeeForm.cs:line 116 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Transparent_Form.Program.Main() in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\Program.cs:line 19 This exception was originally thrown at this call stack: [External Code] Transparent_Form.ManageEmployeeForm.button_update_Click(object, System.EventArgs) in ManageEmployeeForm.cs [External Code] Transparent_Form.Program.Main() in Program.cs
  8. لدي هذا الكود وعند تشفيل البرنامج تظهر رسالة الخطأ " input string was not in a correct format" , علما بأني الحقل هو خقل رئيسي في قاعد البيانات وقرأت انه يمكن اسخدام TryParse؟ Manage Employee Form private void button_update_Click(object sender, EventArgs e) { // update student record int id = Convert.ToInt32(textBox_id.Text); string name = textBox_EmpName.Text; string title = textBoxJob_Title.Text; string position = textBoxPosition.Text; DateTime hdate = dateTimePicker_hd.Value; string country = textBoxCountry.Text; DateTime bdate = dateTimePicker_bd.Value; string phone = textBox_phone.Text; string address = textBox_address.Text; string gender = radioButton_male.Checked ? "Male" : "Female"; //we need to check student age between 10 and 100 int born_year = dateTimePicker_bd.Value.Year; int this_year = DateTime.Now.Year; if ((this_year - born_year) < 10 || (this_year - born_year) > 100) { MessageBox.Show("The employee age must be between 10 and 100", "Invalid Birthdate", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (verify()) { try { // to get photo from picture box MemoryStream ms = new MemoryStream(); pictureBox_employee.Image.Save(ms, pictureBox_employee.Image.RawFormat); byte[] img = ms.ToArray(); if (employee.updateEmployee(id,name, title, position, hdate, country, bdate, gender, phone, address, img)) { showTable(); MessageBox.Show("Employee data update", "Update Employee", MessageBoxButtons.OK, MessageBoxIcon.Information); button_clear.PerformClick(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Empty Field", "Update Employee", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Employee class public bool updateEmployee(int id, string name, string title, string position, DateTime hdate, string country, DateTime bdate, string gender, string phone, string address, byte[] img) { MySqlCommand command = new MySqlCommand("UPDATE `employee` SET `EmpName`=@n,`Job_Title`=@jt,'Position'=@p,'Hiring_Date'=@hd,'Country'=@c,`Birthdate`=@bd,`Gender`=@gd,`Phone`=@ph,`Address`=@adr,`Photo`=@img WHERE `EmpId`= @id", connect.getconnection); //@id,@fn, @ln, @bd, @gd, @ph, @adr, @img command.Parameters.Add("@id", MySqlDbType.Int32).Value = id; command.Parameters.Add("@n", MySqlDbType.VarChar).Value = name; command.Parameters.Add("@jt", MySqlDbType.VarChar).Value = title; command.Parameters.Add("@p", MySqlDbType.VarChar).Value = position; command.Parameters.Add("@hd", MySqlDbType.VarChar).Value = hdate; command.Parameters.Add("@c", MySqlDbType.VarChar).Value = country; command.Parameters.Add("@bd", MySqlDbType.VarChar).Value = bdate; command.Parameters.Add("@gd", MySqlDbType.VarChar).Value = gender; command.Parameters.Add("@ph", MySqlDbType.VarChar).Value = phone; command.Parameters.Add("@adr", MySqlDbType.VarChar).Value = address; command.Parameters.Add("@img", MySqlDbType.Blob).Value = img; connect.openConnect(); if (command.ExecuteNonQuery() == 1) { connect.closeConnect(); return true; } else { connect.closeConnect(); return false; } } //Create a function to delete data //we need only id public bool deleteEmployee(int id) { MySqlCommand command = new MySqlCommand("DELETE FROM `employee` WHERE `EmpId`=@id", connect.getconnection); //@id command.Parameters.Add("@id", MySqlDbType.Int32).Value = id; connect.openConnect(); if (command.ExecuteNonQuery() == 1) { connect.closeConnect(); return true; } else { connect.closeConnect(); return false; } }
  9. شكرا على الرد قمت بادخال البيانات كما ادخلتها في قاعدة البيانات //to create connection MySqlConnection connect = new MySqlConnection("datasource=localhost;port=3306;username=root;password=root;database=employeedb"); //to get connection public MySqlConnection getconnection { get { return connect; } } public DataTable getList(MySqlCommand command) { command.Connection = connect.getconnection; MySqlDataAdapter adapter = new MySqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); return table; } }
  10. عند تشغيل البرنامج والبدء في صفحة تسجيل الدخول تظهر الرسالة المرفقة ارجو المساعدة والتوضيح MySql.Data.MySqlClient.MySqlException: 'Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES)'
  11. ممتاز كيف سيكون التعريف لهذه الدالة لاني ما زلت أواجه نفس الخطا عند تنفيذ المشروع ;Using namespace Orgainization_manager.pal.forms void IsValidNamePass ()string main } ;()IsValidNamePass ;0 return {
  12. اريد تعريف الدالة string Check =Organization_Manager.OrganizationManager.IsValidNamePass(textBoxName.Text.Trim(),textBoxPassword.Text.Trim(),sql); داخل الصنف : namespace Organization_Manager { internal class OrganizationManager { } }
  13. ما الحل الممكن لهذه المشكلة , كان البرنامج يعمل بشكل سليم ثم توقف فجأة
×
×
  • أضف...