public int GetEmpIdByName(string name)
        {
            var query = (from r in edm.Employees where r.EmployeeName == name select r);
            Employee e = new Employee();
            e = query.First<Employee>();
            int id = e.EmployeeID;

            return id;
        }
        public void SendEmailToClerk(int empid, string body, string subject)
        {
            EmployeeBLL empbll = new EmployeeBLL();
            Employee currentuser = new Employee();
            //Employee storeclerk = new Employee();
            currentuser = empbll.GetEmployeeById(empid);
            string toemail = bll.getstoreClerk();

            string bodymsg = "New collection point is :"+ "<br/>" + body + "<br/>With Regards,<br/>" + currentuser.EmployeeName;

            bll.SendEmailToStore(toemail, currentuser.Email, bodymsg, subject);
        }
        public void SendEmailToSupplier(int empid, string body, string subject)
        {
            PurchaseOrderBLL pobll = new PurchaseOrderBLL();

            EmployeeBLL empbll = new EmployeeBLL();
            Employee currentuser = new Employee();
            currentuser = empbll.GetEmployeeById(empid);

            Supplier toSupplier = new Supplier();
            toSupplier = supbll.GetSupplierByName(ddlSupplierList.SelectedValue);

            string bodymsg = "Purchase Order Number: " + poNum + "<br/>" + body + "<br/>With Regards,<br/>" + currentuser.EmployeeName;

            pobll.SendEmailToSupplier(toSupplier.Email, currentuser.Email, bodymsg, subject);
        }
        private string SendEmailNotification(int assignedEmpId, string body, string subject)
        {
            EmployeeBLL emp_Bll = new EmployeeBLL();

            Employee emp_info = new Employee();
            emp_info = emp_Bll.GetEmp_Info(assignedEmpId);  //get emp_info to assign

            int currentUser_Id = Convert.ToInt32(Session["loginUser"]);
            Employee currentUser_info = new Employee();
            currentUser_info = emp_Bll.GetEmp_Info(currentUser_Id); ////get emp_info(current logined user)

            string body_msg = "To" + emp_info.EmployeeName + body + "From" + currentUser_info.EmployeeName;
            string ToEmail = emp_Bll.getToEmailid(emp_Nmae);

            //public void sendEmailNotification(string toEmail, string fromEmail, string body, string subject)
            string msg = emp_Bll.sendEmailNotification(ToEmail, currentUser_info.Email, body_msg, subject);
            return msg;
        }
        public string GetEmployeeNameById(int id)
        {
            var query = (from r in edm.Employees where r.EmployeeID == id select r);
            Employee e = new Employee();
            e = query.First<Employee>();
            string name = e.EmployeeName;

            return name;
        }
 public Employee GetEmployeeById(int id)
 {
     var q = (from r in edm.Employees where r.EmployeeID == id select r);
     Employee e = new Employee();
     e = q.First<Employee>();
     return e;
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            adjustment_View adjust_view = new adjustment_View();
            AdjustmentBLL adjustbll = new AdjustmentBLL();

            //int adjustBy_Id = 1005;
              // int loginUserId = 1002;// current login User who will make Adjustment Report
            int loginUserId = Convert.ToInt32(Session["loginUser"]);
            DateTime adjustDate = DateTime.Now;
            //DateTime adjustDate = DateTime.Today;

            int itemPrice = Convert.ToInt32(ddlPrice.SelectedItem.Value);

            //int approvedBy = null;
            //DateTime approveDate = null;
            //string approveStatus = null;
            double total_price = 0;
            foreach (GridViewRow row in gvAdjustList.Rows)
            {

                string item_code = row.Cells[1].Text;
                int qty = Convert.ToInt32(row.Cells[2].Text);

                StockItemBLL itemBll = new StockItemBLL();
                double price = itemBll.GetItemPrice(item_code);

                total_price = total_price + (price * qty);

                /********* Don't delete lbl testing line **********/
                //lblPrice.Text = price.ToString();
                //lblTotalPrice.Text = total_price.ToString(); // don't delete

            }
            string authorizedBy = null;

            if (total_price <= 250)
            {
                authorizedBy = "Supervisor";
            }
            else
            {
                authorizedBy = "Manager";
            }
            int adjustid = adjustbll.addAdjustment(loginUserId, adjustDate, authorizedBy);

            foreach (GridViewRow row in gvAdjustList.Rows)
            {
                string item_code = row.Cells[1].Text;
                int qty = Convert.ToInt32(row.Cells[2].Text);
                string reason = row.Cells[3].Text;
                string status = row.Cells[4].Text;

                AdjustmentDetailsBLL adjust_details_bll = new AdjustmentDetailsBLL();
                int adjustment_details_Id = adjust_details_bll.addAdjustmentDetails(adjustid, item_code, qty, reason, status);

            }

            Employee emp_bll = new Employee();
            //int loginUserId = 1002;
            string email_body = "Adjustment Report is submitted to Supervier or Manager by StoreClerk";
            string email_subj = "Issue Adjustment Report";
            string email_msg = SendEmailNotification(loginUserId, email_body, email_subj, authorizedBy);

            lblSubmitMsg.Text = "Adjustment Report Submittion is successful. " + email_msg;
        }
        private string SendEmailNotification(int loginUserId, string body, string subject, string authorizedPerson)
        {
            EmployeeBLL emp_Bll = new EmployeeBLL();

            Employee login_EmpInfo = new Employee();
            login_EmpInfo = emp_Bll.GetEmp_Info(loginUserId);  //to get loginEmp_info

            int authorized_ID = 0;
            if (authorizedPerson == "Supervisor")
                authorized_ID = 1007;

            else if (authorizedPerson == "Manager")
                authorized_ID = 1009;

            Employee authorizedPerson_info = new Employee();
            authorizedPerson_info = emp_Bll.GetAuthorizedPersonInfo(authorized_ID);  ////get authorized emp_info

            string body_msg = "To " + authorizedPerson_info.EmployeeName + "<br/>" + body + "<br/>From" + login_EmpInfo.EmployeeName;

            //public void sendEmailNotification(string toEmail, string fromEmail, string body, string subject)
            string msg = emp_Bll.sendEmailNotification(authorizedPerson_info.Email, login_EmpInfo.Email, body_msg, subject);
            return msg;
        }
        void SendNotification()
        {
            EmployeeBLL empbll = new EmployeeBLL();
            Employee employeeinfo = new Employee();
            Employee headinfo = new Employee();

            int empid = Convert.ToInt32(Session["loginUser"]);
               // int empid = 1004; //to update empid
            employeeinfo = empbll.getEmployeebyempid(empid);

            headinfo = empbll.getEmailAddressbyempType(employeeinfo.DepartmentCode, "head"); //to update employee type

            String body = "Please help to approve my stationery request! Thanks.\n" + "Best Regards,\n" + employeeinfo.EmployeeName;
            String subject = "Stationery Request from " + employeeinfo.EmployeeName;

            emreqbll.sendNotificationToDeptHead(headinfo.Email, employeeinfo.Email, body, subject);
        }
        void SendNotification(int empid, string body, string subject)
        {
            DepartmentRequBLL deptreqBll = new DepartmentRequBLL();
            int currentuserid = Convert.ToInt32(Session["loginUser"]);
            //int currentuserid = Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name.ToString());
            //int currentuserid = 1004; //to update empid
            EmployeeBLL empbll = new EmployeeBLL();
            Employee employeeinfo = new Employee();
            Employee currentuserinfo = new Employee();

            employeeinfo = empbll.getEmployeebyempid(empid);

            currentuserinfo = empbll.getEmployeebyempid(currentuserid); //to update employee type
            string body1 = body + currentuserinfo.EmployeeName;

            deptreqBll.sendNotificationToEmployee(employeeinfo.Email, currentuserinfo.Email, body1, subject);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmployees(Employee employee)
 {
     base.AddObject("Employees", employee);
 }
 /// <summary>
 /// Create a new Employee object.
 /// </summary>
 /// <param name="employeeID">Initial value of the EmployeeID property.</param>
 /// <param name="employeeName">Initial value of the EmployeeName property.</param>
 /// <param name="departmentCode">Initial value of the DepartmentCode property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="employeeType">Initial value of the EmployeeType property.</param>
 public static Employee CreateEmployee(global::System.Int32 employeeID, global::System.String employeeName, global::System.String departmentCode, global::System.String email, global::System.String employeeType)
 {
     Employee employee = new Employee();
     employee.EmployeeID = employeeID;
     employee.EmployeeName = employeeName;
     employee.DepartmentCode = departmentCode;
     employee.Email = email;
     employee.EmployeeType = employeeType;
     return employee;
 }