Esempio n. 1
0
        public static string GetAmanaNameByEmp(object CurrUser)
        {
            string res = string.Empty;

            try
            {
                tblEmployee emp = (tblEmployee)CurrUser;

                tblEmployeesCivilRegistry employeesCivilRegistry = GetCivilRegistryEmployee(emp.NationalNumber);

                if (employeesCivilRegistry != null)
                {
                    using (EGovernmentEntities db = new EGovernmentEntities())
                    {
                        tblCivilRegistry civilRegistry = db.tblCivilRegistries.Where(x => x.Id == employeesCivilRegistry.CivilRegistryID).FirstOrDefault();
                        if (civilRegistry != null)
                        {
                            res = civilRegistry.Name;
                        }
                    }
                }
            }
            catch { res = "الأمانة المركزية"; }

            return(res);
        }
Esempio n. 2
0
        protected void btnLogIn_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                bool IsCitizen = true;
                if (Helper.CheckUserName(txtUserName.Value))
                {
                    if (Helper.CheckPassWord(txtPassword.Value, txtUserName.Value))
                    {
                        //Session["UserName"] = txtUserName.Value;
                        string      nationalNum = Helper.GetEmployeeId(txtUserName.Value);
                        tblEmployee emp         = Helper.GetEmployee(nationalNum);
                        if (emp != null)
                        {
                            tblEmployeesCivilRegistry employeeCivilRegistry = Helper.GetActiveEmployeeRecord(nationalNum);

                            if (employeeCivilRegistry != null)
                            {
                                Session["CurrUser"] = emp;

                                Session["Role"] = Helper.GetRoleById(employeeCivilRegistry.RoleId);

                                IsCitizen = false;
                            }
                        }
                        else if (IsCitizen)
                        {
                            bool ConfirmUser = Helper.IsConfirm(txtUserName.Value);
                            if (ConfirmUser)
                            {
                                Session["Role"] = Helper.GetRoleById(2);
                            }
                            else
                            {
                                Response.Redirect("/403");
                            }
                        }

                        Session["CitizenNN"] = Helper.GetNNByUserName(txtUserName.Value);
                        Session["UserName"]  = txtUserName.Value;
                        Response.Redirect("/Administration/Default");
                    }
                    else
                    {
                        FailureText.Text     = "كلمة المرور خاطئة";
                        ErrorMessage.Visible = true;
                    }
                }
                else
                {
                    FailureText.Text     = "اسم المستخدم غير موجود";
                    ErrorMessage.Visible = true;
                }
            }
        }
Esempio n. 3
0
        public static void UnController(List <tblEmployee> lstEmployees)
        {
            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                foreach (tblEmployee emp in lstEmployees)
                {
                    tblEmployeesCivilRegistry employeesCivilRegistry = db.tblEmployeesCivilRegistries.Where(x => x.EmployeNationalNumber == emp.NationalNumber).Where(y => y.E_date == null).FirstOrDefault();

                    employeesCivilRegistry.IsController = false;
                }
                db.SaveChanges();
            }
        }
Esempio n. 4
0
        public static tblRole GetEmployeeRole(string NationalNumber)
        {
            tblRole role = null;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblEmployeesCivilRegistry employeesCivilRegistry = db.tblEmployeesCivilRegistries.Where(x => x.EmployeNationalNumber == NationalNumber).Where(y => y.E_date == null).FirstOrDefault();
                if (employeesCivilRegistry != null)
                {
                    role = db.tblRoles.Where(x => x.Id == employeesCivilRegistry.RoleId).FirstOrDefault();
                }
            }

            return(role);
        }
Esempio n. 5
0
        public static bool IsEmployee(string NationalNumber)
        {
            bool res = false;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblEmployeesCivilRegistry employee = db.tblEmployeesCivilRegistries.Where(x => x.EmployeNationalNumber == NationalNumber).OrderByDescending(x => x.Id).FirstOrDefault();

                if (employee != null)
                {
                    res = employee.E_date == null;
                }
            }

            return(res);
        }
Esempio n. 6
0
        public static string GetCivilRegistrarByEmp(object CurrUser)
        {
            string res = string.Empty;

            try
            {
                tblEmployee emp = (tblEmployee)CurrUser;

                tblEmployeesCivilRegistry employeesCivilRegistry = GetCivilRegistryEmployee(emp.NationalNumber);

                if (employeesCivilRegistry != null)
                {
                    res = GetCivilRegistrarById(Convert.ToInt32(employeesCivilRegistry.CivilRegistryID));
                }
            }
            catch { res = "نزار المسعود"; }

            return(res);
        }
Esempio n. 7
0
        public static string GetRank(tblEmployeesCivilRegistry tblEmployeesCivilRegistry)
        {
            string rank = string.Empty;

            if (tblEmployeesCivilRegistry.IsManager == true)
            {
                rank = "مدير";
            }
            else if (tblEmployeesCivilRegistry.IsController == true)
            {
                rank = "مراقب";
            }
            else if (tblEmployeesCivilRegistry.IsCivilRegisterer == true)
            {
                rank = "أمين السجل المدني";
            }
            else
            {
                rank = "موظف عادي";
            }
            return(rank);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                using (EGovernmentEntities db = new EGovernmentEntities())
                {
                    EditPage = (btnAdd.Text == "حفظ التعديلات");
                    tblEmployee employee;
                    if (EditPage)
                    {
                        employee = db.tblEmployees.Where(x => x.NationalNumber == labelNationalNum.Text).FirstOrDefault();
                    }
                    else
                    {
                        employee = new tblEmployee();
                    }

                    var citizen = db.tblCitizens.Where(b => b.NationalNumber == EmployeeNationalNum.Text).FirstOrDefault();
                    employee.NationalNumber = labelNationalNum.Text;
                    employee.Address        = txtAddress.Text;
                    employee.Specialization = txtSpecialization.Text;
                    employee.Phone          = txtPhoneNumber.Text;

                    if (!EditPage)
                    {
                        if (db.tblEmployees.Where(x => x.NationalNumber == employee.NationalNumber).ToList().Count == 0)
                        {
                            db.tblEmployees.AddObject(employee);
                        }
                    }

                    tblEmployeesCivilRegistry empcivil;
                    if (EditPage)
                    {
                        empcivil = db.tblEmployeesCivilRegistries.Where(x => x.EmployeNationalNumber == labelNationalNum.Text).OrderByDescending(x => x.Id).FirstOrDefault();
                    }
                    else
                    {
                        empcivil = new tblEmployeesCivilRegistry();
                    }

                    empcivil.IsManager         = rdoManager.Checked;
                    empcivil.IsCivilRegisterer = rdoIsCivilRegisterer.Checked;
                    empcivil.IsController      = rdoIsController.Checked;
                    empcivil.RoleId            = int.Parse(ddlRole.SelectedValue);
                    if (!CheckBox1.Checked)
                    {
                        empcivil.E_date = DateTime.Now;
                    }

                    int CivilRegistryID = int.Parse(ddlCivilRegistry.SelectedValue);
                    if (!rdoManager.Checked)
                    {
                        empcivil.CivilRegistryID = CivilRegistryID;
                    }

                    empcivil.EmployeNationalNumber = employee.NationalNumber;
                    empcivil.S_date = DateTime.Now;

                    if (!EditPage)
                    {
                        db.tblEmployeesCivilRegistries.AddObject(empcivil);
                    }

                    if (Convert.ToBoolean(empcivil.IsManager))
                    {
                        List <tblEmployee> lstEmployees = Helper.GetEmployeeByAffairs(CivilRegistryID);
                        Helper.UnManager(lstEmployees);
                    }

                    if (Convert.ToBoolean(empcivil.IsCivilRegisterer))
                    {
                        List <tblEmployee> lstEmployees = Helper.GetEmployeeByCivilRegisterar(CivilRegistryID);
                        Helper.UnCivilRegisterer(lstEmployees);
                    }

                    if (Convert.ToBoolean(empcivil.IsController))
                    {
                        List <tblEmployee> lstEmployees = Helper.GetEmployeeByCivilRegisterar(CivilRegistryID);
                        Helper.UnController(lstEmployees);
                    }



                    db.SaveChanges();

                    Response.Redirect("/Finish");
                }
            }
        }