Esempio n. 1
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (comboBoxEmplyees.SelectedIndex == -1)
            {
                MessageBox.Show("يجب اختيار موظف");
                return;
            }

            Emplyee emp = emplyeeList[comboBoxEmplyees.SelectedIndex];

            if (int.TryParse(textBoxPrice.Text, out int price))
            {
                Deduction deduction = new Deduction()
                {
                    DeductionValue = price,
                    Reson          = textBoxDetails.Text,
                    Date           = pickerStartDate.SelectedDate ?? DateTime.Now,
                    Emplyee_Name   = emp.Name,
                    Emplyee_Id     = emp.Id,
                    Notes          = textBoxNotes.Text
                };

                emplyeeData.AddDeduction(deduction);

                MessageBox.Show("تم الحفظ");
            }
            else
            {
                MessageBox.Show("تاكد من قيمة الخصم \\ السلفة");
            }
        }
Esempio n. 2
0
        public Emplyee getEmployee()
        {
            var emp = new Emplyee();

            SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DataContext"].ToString());
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection  = cnn;
            cmd.CommandText = "select * from Emplyees";
            cnn.Open();

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                emp.EmplyeeId = int.Parse(reader.GetValue(0).ToString());

                emp.EmpName = reader.GetValue(1).ToString();
            }


            reader.Close();
            cmd.Dispose();
            cnn.Close();
            return(emp);
        }
Esempio n. 3
0
        public int AddEmplyee(Emplyee emplyee)
        {
            int result = -1;

            using (SQLiteConnection conn = new SQLiteConnection(sQLiteConnection))
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(conn))
                {
                    cmd.CommandText = "INSERT INTO TA_Emplyee(Name, Moble, Salary) VALUES (@name, @Moble, @Salary)";
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@name", emplyee.Name);
                    cmd.Parameters.AddWithValue("@Moble", emplyee.Moble);
                    cmd.Parameters.AddWithValue("@Salary", emplyee.Salary);
                    try
                    {
                        result = cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException e)
                    {
                    }
                }
                conn.Close();
            }
            return(result);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Emplyee emplyee = db.Emplyees.Find(id);

            db.Emplyees.Remove(emplyee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "EmplyeeID,FirstName,LastName,Salary,BonusPercent,DateOfBirth,StartDate,Email,URL,DocumentTypeID")] Emplyee emplyee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emplyee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DocumentTypeID = new SelectList(db.DocumentTypes, "DocumentTypeID", "Description", emplyee.DocumentTypeID);
     return(View(emplyee));
 }
Esempio n. 6
0
        private void ListBoxEmplyees_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            textBoxEmplyees.Text = "";
            empsIds = "";

            foreach (var item in listBoxEmplyees.SelectedItems)
            {
                Emplyee emp = item as Emplyee;
                textBoxEmplyees.Text = textBoxEmplyees.Text + emp.Name + ", ";
                empsIds = empsIds + emp.Id + ",";
            }
        }
        public ActionResult Create([Bind(Include = "EmplyeeID,FirstName,LastName,Salary,BonusPercent,DateOfBirth,StartDate,Email,URL,DocumentTypeID")] Emplyee emplyee)
        {
            if (ModelState.IsValid)
            {
                db.Emplyees.Add(emplyee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DocumentTypeID = new SelectList(CombosHelper.GetDocumentTypes(), "DocumentTypeID", "Description", emplyee.DocumentTypeID);
            return(View(emplyee));
        }
Esempio n. 8
0
 public ActionResult Create(Emplyee emplyee)
 {
     try
     {
         db.Emplyees.Add(emplyee);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(emplyee));
     }
 }
Esempio n. 9
0
        public int UpdateData(Emplyee emp)
        {
            SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DataContext"].ToString());
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection  = cnn;
            cmd.CommandText = "update Emplyees set EmpName='" + emp.EmpName + "' where EmplyeeId=" + emp.EmplyeeId;
            cnn.Open();
            int i = cmd.ExecuteNonQuery();

            cnn.Close();
            return(i);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Emplyee emplyee = new Emplyee();

            emplyee.id     = 101;
            emplyee.namd   = "Adil";
            emplyee.age    = 30;
            emplyee.salary = 10950;

            emplyee emplyee1 = new emplyee();

            Console.WriteLine("Hello World!");
        }
Esempio n. 11
0
        public async Task <IActionResult> CreateEmployee(EmployeeModel employeeModel)
        {
            if (ModelState.IsValid)
            {
                Emplyee emplyee = new Emplyee {
                    LastName = employeeModel.LastName, Name = employeeModel.Name, PositionId = employeeModel.PositionId
                };
                _context.Emplyee.Add(emplyee);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Employee", "Managment"));
            }
            return(View(employeeModel));
        }
        // GET: Emplyees/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Emplyee emplyee = db.Emplyees.Find(id);

            if (emplyee == null)
            {
                return(HttpNotFound());
            }
            return(View(emplyee));
        }
        // GET: Emplyees/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Emplyee emplyee = db.Emplyees.Find(id);

            if (emplyee == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DocumentTypeID = new SelectList(db.DocumentTypes, "DocumentTypeID", "Description", emplyee.DocumentTypeID);
            return(View(emplyee));
        }
Esempio n. 14
0
        public ActionResult Edit(int id, Emplyee emplyee)
        {
            try
            {
                db.Entry(emplyee).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 15
0
        public ActionResult Delete(int id, Emplyee emplyee)
        {
            try
            {
                emplyee.EmplyeeId = id;

                db.Entry(emplyee).State = System.Data.Entity.EntityState.Deleted;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 16
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            EmplyeeData emplyeeData = new EmplyeeData();

            float.TryParse(textBoxSalary.Text, out float salary);

            Emplyee emplyee = new Emplyee()
            {
                Name   = textBoxName.Text,
                Moble  = textBoxMobile.Text,
                Salary = salary
            };

            emplyeeData.AddEmplyee(emplyee);

            MessageBox.Show("تم الحفظ");
        }
Esempio n. 17
0
        private void EmplyeesGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (e.AddedCells.Count > 0)
            {
                if (e.AddedCells[0].Column.Header.ToString() == "Delete")
                {
                    Emplyee emplyee = e.AddedCells[0].Item as Emplyee;
                    if (MessageBox.Show($" حذف {emplyee.Name}", "تأكيد الحذف", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.OK)
                        == MessageBoxResult.OK)
                    {
                        Emplyees.Remove(emplyee);
                        CalcTotal(Emplyees);
                        MessageBox.Show($" تم حذف {emplyee.Name}");

                        EmplyeesGrid.ItemsSource = null;
                        EmplyeesGrid.ItemsSource = Emplyees;
                        EmplyeesGrid.Items.Refresh();

                        data.Delete(emplyee.Id, "TA_Emplyee");
                    }
                }
            }
        }
Esempio n. 18
0
        public List <Emplyee> GetAllEmplyee()
        {
            List <Emplyee> data = new List <Emplyee>();

            try
            {
                using (SQLiteConnection conn = new SQLiteConnection(sQLiteConnection))
                {
                    conn.Open();
                    string sql = "SELECT * FROM TA_Emplyee ";

                    using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
                    {
                        using (SQLiteDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Emplyee emplyee = new Emplyee
                                {
                                    Id     = Convert.ToInt32(reader["Id"]),
                                    Name   = reader["Name"].ToString(),
                                    Salary = float.Parse(reader["Salary"].ToString()),
                                    Moble  = reader["Moble"].ToString()
                                };

                                data.Add(emplyee);
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (SQLiteException e)
            {
            }
            return(data);
        }