public Boolean validateEmployeePosting(employeeposting empposting)
        {
            Boolean status = true;

            try
            {
                if (empposting.empID == 0)
                {
                    return(false);
                }
                if (empposting.officeID == null || empposting.officeID.Trim().Length == 0)
                {
                    return(false);
                }
                if (empposting.departmentID == null || empposting.departmentID.Trim().Length == 0)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                return(false);
            }

            return(status);
        }
Exemple #2
0
        public static List <employeeposting> getEmployeePostingListForLeaveOB()
        {
            employeeposting        emppostingrec;
            List <employeeposting> EmployeePosting = new List <employeeposting>();

            try
            {
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "Select distinct cast(a.EmployeeID as integer), a.Name, a.OfficeID, a.OfficeName from ViewEmployeeDetails a" +
                                      " where a.status = 1  order by cast(a.EmployeeID as integer)";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    emppostingrec            = new employeeposting();
                    emppostingrec.empID      = reader.GetInt32(0);
                    emppostingrec.empName    = reader.GetString(1);
                    emppostingrec.officeID   = reader.IsDBNull(2) ? "" : reader.GetString(2);
                    emppostingrec.officeName = reader.IsDBNull(3) ? "" : reader.GetString(3);
                    EmployeePosting.Add(emppostingrec);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(EmployeePosting);
        }
        public Boolean insertEmployeePosting(employeeposting empposting)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "insert into EmployeePosting (EmployeeID,PostingDate,OfficeID,Department,ReportingOfficerID,Remarks,Status,CreateTime,CreateUser) values (" +
                                   "'" + empposting.empID + "'," +
                                   "'" + (empposting.postingDate.ToString("yyyyMMdd")) + "'," +
                                   "'" + empposting.officeID + "'," +
                                   "'" + empposting.departmentID + "'," +
                                   "'" + empposting.ReportingOfficer + "'," +
                                   "'" + empposting.remarks + "'," +
                                   empposting.Status + "," +
                                   "GETDATE()" + "," +
                                   "'" + Login.userLoggedIn + "'" + ")";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("insert", "EmployeePosting", "", updateSQL) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
        public static Boolean updateEmpPosting(string rowid, employeeposting empPost)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                SqlConnection con   = new SqlConnection(Login.connString);
                string        query = "update EmployeePosting set" +
                                      " PostingDate='" + (empPost.postingDate.ToString("yyyyMMdd")) + "'," +
                                      " OfficeID='" + empPost.officeID + "'," +
                                      " Department='" + empPost.departmentID + "'," +
                                      " Remarks='" + empPost.remarks + "'," +
                                      " Status=" + empPost.Status +
                                      " , ReportingOfficerID = '" + empPost.ReportingOfficer + "'" +
                                      " where RowID=" + rowid + "";
                SqlCommand cmd = new SqlCommand(query, con);
                con.Open();
                //cmd.Parameters.Add("@emp.empPicture", emp.empPicture);
                utString = utString + query + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "EmployeePosting", "", query) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
        //public static List<employeeposting> getEmployeeListForQC()
        //{
        //    employeeposting empPosting;
        //    List<employeeposting> empPostingList = new List<employeeposting>();
        //    try
        //    {
        //        //string connString = "Data Source = PRAKASHPC; Initial Catalog = newERP; Integrated Security = True";
        //        SqlConnection conn = new SqlConnection(Login.connString);
        //        string query = "Select EmployeeID, Name,UserID, OfficeID, Department " +
        //            " from ViewEmployeeLocation " +
        //            "where status = 1 and isnull(UserID,' ') != ' ' and officeID = 'CSLB' and( Department = 'Production' or  Department = 'QC') order by PostingDate desc, CreateTime desc";
        //        SqlCommand cmd = new SqlCommand(query, conn);
        //        conn.Open();
        //        SqlDataReader reader = cmd.ExecuteReader();
        //        while (reader.Read())
        //        {
        //            empPosting = new employeeposting();
        //            empPosting.empID = Convert.ToInt32(reader.GetString(0));
        //            empPosting.empName = reader.GetString(1);
        //            empPosting.UserID = reader.GetString(2);
        //            empPosting.officeID = reader.GetString(3);
        //            empPosting.departmentID = reader.GetString(4);
        //            empPostingList.Add(empPosting);
        //        }
        //        conn.Close();
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(this.ToString() + "-"+ System.Reflection.MethodBase.GetCurrentMethod().Name+"() : Error");
        //    }
        //    return empPostingList;
        //}
        public static List <employeeposting> getEmployeeList(string departments)
        {
            employeeposting        empPosting;
            List <employeeposting> empPostingList = new List <employeeposting>();

            try
            {
                string   inStr = "";
                string[] lst1  = departments.Split(Main.delimiter1);
                for (int i = 0; i < lst1.Length; i++)
                {
                    if (lst1[i].Trim().Length > 0)
                    {
                        if (inStr.Trim().Length > 0)
                        {
                            inStr = inStr + ",";
                        }
                        inStr = inStr + "'" + lst1[i] + "'";
                    }
                }
                //string connString = "Data Source = PRAKASHPC; Initial Catalog = newERP; Integrated Security = True";
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "Select EmployeeID, Name,UserID, OfficeID, Department,ReportingOfficerID " +
                                      " from ViewEmployeeLocation " +
                                      " where status = 1 and isnull(UserID,' ') != ' ' and officeID in ( 'BLR','NVP') " +
                                      " and Department in (" + inStr + ") " +
                                      " order by PostingDate desc, CreateTime desc";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    empPosting                  = new employeeposting();
                    empPosting.empID            = Convert.ToInt32(reader.GetString(0));
                    empPosting.empName          = reader.GetString(1);
                    empPosting.UserID           = reader.GetString(2);
                    empPosting.officeID         = reader.GetString(3);
                    empPosting.departmentID     = reader.GetString(4);
                    empPosting.ReportingOfficer = reader.IsDBNull(5) ? "" : reader.GetString(5);
                    empPostingList.Add(empPosting);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(empPostingList);
        }
        public static List <employeeposting> getEmployeePosting(string empID)
        {
            employeeposting        emppostingrec;
            List <employeeposting> EmployeePosting = new List <employeeposting>();

            try
            {
                //string connString = "Data Source = PRAKASHPC; Initial Catalog = newERP; Integrated Security = True";
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "Select EmployeeID, Name, PostingDate, OfficeID, OfficeName, Department, DepartmentName, " +
                                      "Remarks,Status,CreateTime,CreateUser,CreatorName,ReportingOfficerID,ReportingOfficerName,RowID from ViewEmployeePosting " +
                                      "where  EmployeeID = '" + empID + "' order by PostingDate asc, CreateTime asc";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    emppostingrec = new employeeposting();
                    string s = reader.GetString(1);
                    emppostingrec.empID                = Convert.ToInt32(reader.GetString(0));
                    emppostingrec.empName              = reader.GetString(1);
                    emppostingrec.postingDate          = reader.GetDateTime(2);
                    emppostingrec.officeID             = reader.GetString(3);
                    emppostingrec.officeName           = reader.GetString(4);
                    emppostingrec.departmentID         = reader.GetString(5);
                    emppostingrec.departmentName       = reader.GetString(6);
                    emppostingrec.remarks              = reader.GetString(7);
                    emppostingrec.Status               = reader.GetInt32(8);
                    emppostingrec.createTime           = reader.GetDateTime(9);
                    emppostingrec.createUser           = reader.GetString(10);
                    emppostingrec.createUserName       = reader.GetString(11);
                    emppostingrec.ReportingOfficer     = reader.IsDBNull(12) ? "" : reader.GetString(12);
                    emppostingrec.ReportingOfficername = reader.IsDBNull(13) ? "" : reader.GetString(13);
                    emppostingrec.RowID                = reader.GetInt32(14);
                    EmployeePosting.Add(emppostingrec);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(EmployeePosting);
        }
        public static List <employeeposting> getEmployeePostingList()
        {
            employeeposting        emppostingrec;
            List <employeeposting> EmployeePosting = new List <employeeposting>();

            try
            {
                //string connString = "Data Source = PRAKASHPC; Initial Catalog = newERP; Integrated Security = True";
                SqlConnection conn = new SqlConnection(Login.connString);
                ////string query = "Select distinct a.EmployeeID, a.Name, a.OfficeID, a.OfficeName from ViewEmployeePosting a" +
                ////    " where a.status = 1 and a.postingdate= (select MAX(b.postingdate) "+
                ////    " from ViewEmployeePosting b where b.EmployeeID=a.EmployeeID) order by a.EmployeeID";
                string query = "Select distinct a.EmployeeID, a.Name, a.OfficeID, a.OfficeName from ViewEmployeeDetails a" +
                               " where a.status = 1  order by a.EmployeeID";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (!reader.HasRows)
                {
                    emppostingrec            = new employeeposting();
                    emppostingrec.empID      = 99999;
                    emppostingrec.empName    = "Developer";
                    emppostingrec.officeID   = "";
                    emppostingrec.officeName = "";
                    EmployeePosting.Add(emppostingrec);
                }
                while (reader.Read())
                {
                    emppostingrec         = new employeeposting();
                    emppostingrec.empID   = Convert.ToInt32(reader.GetString(0));
                    emppostingrec.empName = reader.GetString(1);

                    emppostingrec.officeID   = reader.IsDBNull(2) ? "" : reader.GetString(2);
                    emppostingrec.officeName = reader.IsDBNull(3) ? "" : reader.GetString(3);
                    EmployeePosting.Add(emppostingrec);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(EmployeePosting);
        }