Ejemplo n.º 1
0
        public void CreateForm1Display(string leaveID)
        {
            Form1Package f1 = DatabaseManager.GetForm1Package(leaveID);

            if (f1 != null)
            {
                lbLeaveID.Text    = f1.LeaveID;
                lbReqDate.Text    = f1.RequestDate;
                lbName.Text       = f1.PersonPrefix + f1.PersonFirstName + " " + f1.PersonLastName;
                lbPosition.Text   = f1.PersonPosition;
                lbRank.Text       = f1.PersonRank;
                lbDepartment.Text = f1.PersonDepartment;
                lbLeaveType.Text  = f1.LeaveTypeName;
                lbFromDate.Text   = f1.FromDate;
                lbToDate.Text     = f1.ToDate;
                lbTotalDay.Text   = f1.TotalDay + " วัน";
                lbReason.Text     = f1.Reason;
                lbContact.Text    = f1.Contact;
                lbPhone.Text      = f1.Phone;
                if (f1.LastFromDate == "")
                {
                    lbLastFromDate.Text = "-";
                    lbLastToDate.Text   = "-";
                    lbLastTotalDay.Text = "-";
                }
                else
                {
                    lbLastFromDate.Text = f1.LastFromDate;
                    lbLastToDate.Text   = f1.LastToDate;
                    lbLastTotalDay.Text = f1.LastTotalDay + " วัน";
                }

                lbCmdLowName.Text      = f1.CommanderLowPrefix + f1.CommanderLowFirstName + " " + f1.CommanderLowLastName;
                lbCmdLowPosition.Text  = f1.CommanderLowPosition;
                lbCmdLowComment.Text   = f1.CommanderLowComment;
                lbCmdLowDate.Text      = f1.CommanderLowDate;
                lbCmdHighName.Text     = f1.CommanderHighPrefix + f1.CommanderHighFirstName + " " + f1.CommanderHighLastName;
                lbCmdHighPosition.Text = f1.CommanderHighPosition;
                lbCmdHighComment.Text  = f1.CommanderHighComment;
                lbCmdHighDate.Text     = f1.CommanderHighDate;
                lbCmdHighAllow.Text    = f1.CommanderHighAllowName;
                lbStaffName.Text       = f1.StaffPrefix + f1.StaffFirstName + " " + f1.StaffLastName;
                lbStaffPosition.Text   = f1.StaffPosition;
                lbStaffDate.Text       = f1.StaffDate;
            }
        }
Ejemplo n.º 2
0
        public static Form1Package GetForm1Package(string leaveID)
        {
            try {
                int.Parse(leaveID);
            } catch {
                return(null);
            }
            using (OleDbConnection con = new OleDbConnection(CONNECTION_STRING)) {
                con.Open();
                using (OleDbCommand com = new OleDbCommand("SELECT LEV_MAIN.*, LEV_FORM1.*, (SELECT LEAVE_TYPE_NAME FROM LEV_MAIN, LEV_TYPE WHERE LEV_MAIN.LEAVE_TYPE_ID = LEV_TYPE.LEAVE_TYPE_ID AND LEV_MAIN.LEAVE_ID = " + leaveID + "), (SELECT LEAVE_ALLOW_NAME FROM LEV_FORM1, LEV_ALLOW WHERE CMD_HIGH_ALLOW = LEAVE_ALLOW_ID AND LEV_FORM1.LEAVE_ID = " + leaveID + ") FROM LEV_MAIN, LEV_FORM1 WHERE LEV_MAIN.LEAVE_TYPE_ID in(1,2,3) AND LEV_MAIN.LEAVE_ID = LEV_FORM1.LEAVE_ID AND LEV_MAIN.LEAVE_ID = " + leaveID, con)) {
                    using (OleDbDataReader reader = com.ExecuteReader()) {
                        while (reader.Read())
                        {
                            Form1Package form1Package = new Form1Package();
                            form1Package.LeaveID     = reader.GetValue(0).ToString();
                            form1Package.LeaveTypeID = reader.GetValue(1).ToString();
                            form1Package.LeaveState  = reader.GetValue(2).ToString();
                            form1Package.CitizenID   = reader.GetValue(3).ToString();
                            form1Package.RequestDate = Util.PureDatabaseToThaiDate(reader.GetValue(4).ToString());
                            form1Package.FormID      = reader.GetValue(5).ToString();

                            form1Package.FromDate               = Util.PureDatabaseToThaiDate(reader.GetValue(7).ToString());
                            form1Package.ToDate                 = Util.PureDatabaseToThaiDate(reader.GetValue(8).ToString());
                            form1Package.TotalDay               = reader.GetValue(9).ToString();
                            form1Package.Reason                 = reader.GetValue(10).ToString();
                            form1Package.Contact                = reader.GetValue(11).ToString();
                            form1Package.Phone                  = reader.GetValue(12).ToString();
                            form1Package.PersonPosition         = reader.GetValue(13).ToString();
                            form1Package.PersonRank             = reader.GetValue(14).ToString();
                            form1Package.PersonDepartment       = reader.GetValue(15).ToString();
                            form1Package.LastFromDate           = Util.PureDatabaseToThaiDate(reader.GetValue(16).ToString());
                            form1Package.LastToDate             = Util.PureDatabaseToThaiDate(reader.GetValue(17).ToString());
                            form1Package.LastTotalDay           = reader.GetValue(18).ToString();
                            form1Package.PersonPrefix           = reader.GetValue(19).ToString();
                            form1Package.PersonFirstName        = reader.GetValue(20).ToString();
                            form1Package.PersonLastName         = reader.GetValue(21).ToString();
                            form1Package.CommanderLowID         = reader.GetValue(22).ToString();
                            form1Package.CommanderLowPosition   = reader.GetValue(23).ToString();
                            form1Package.CommanderLowComment    = reader.GetValue(24).ToString();
                            form1Package.CommanderLowDate       = Util.PureDatabaseToThaiDate(reader.GetValue(25).ToString());
                            form1Package.CommanderHighID        = reader.GetValue(26).ToString();
                            form1Package.CommanderHighPosition  = reader.GetValue(27).ToString();
                            form1Package.CommanderHighComment   = reader.GetValue(28).ToString();
                            form1Package.CommanderHighDate      = Util.PureDatabaseToThaiDate(reader.GetValue(29).ToString());
                            form1Package.CommanderHighAllow     = reader.GetValue(30).ToString();
                            form1Package.StaffID                = reader.GetValue(31).ToString();
                            form1Package.StaffPosition          = reader.GetValue(32).ToString();
                            form1Package.StaffDate              = Util.PureDatabaseToThaiDate(reader.GetValue(33).ToString());
                            form1Package.CommanderLowPrefix     = reader.GetValue(34).ToString();
                            form1Package.CommanderLowFirstName  = reader.GetValue(35).ToString();
                            form1Package.CommanderLowLastName   = reader.GetValue(36).ToString();
                            form1Package.CommanderHighPrefix    = reader.GetValue(37).ToString();
                            form1Package.CommanderHighFirstName = reader.GetValue(38).ToString();
                            form1Package.CommanderHighLastName  = reader.GetValue(39).ToString();
                            form1Package.StaffPrefix            = reader.GetValue(40).ToString();
                            form1Package.StaffFirstName         = reader.GetValue(41).ToString();
                            form1Package.StaffLastName          = reader.GetValue(42).ToString();
                            form1Package.LeaveTypeName          = reader.GetValue(43).ToString();
                            form1Package.CommanderHighAllowName = reader.GetValue(44).ToString();

                            return(form1Package);
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PersonnelSystem ps          = PersonnelSystem.GetPersonnelSystem(this);
            Person          loginPerson = ps.LoginPerson;

            int count = DatabaseManager.GetLeaveRequiredCountByCommanderLow(loginPerson.CitizenID);;

            /*using (OleDbConnection con = new OleDbConnection(DatabaseManager.CONNECTION_STRING)) {
             *  con.Open();
             *  using (OleDbCommand com = new OleDbCommand("SELECT COUNT(LEV_MAIN.LEAVE_ID) FROM LEV_MAIN, LEV_FORM1 WHERE LEV_MAIN.LEAVE_ID = LEV_FORM1.LEAVE_ID AND CMD_LOW_ID = '" + loginPerson.CitizenID + "' AND LEAVE_STATE = 1", con)) {
             *      using (OleDbDataReader reader = com.ExecuteReader()) {
             *          while (reader.Read()) {
             *              count = int.Parse(reader.GetValue(0).ToString());
             *          }
             *      }
             *  }
             * }*/
            if (count == 0)
            {
                error_area.InnerHtml = "ไม่มีรายการที่ท่านต้องลงความเห็น";
            }
            else
            {
                error_area.InnerHtml = "กรุณาเลือกรายการที่ต้องการลงความเห็น";
            }
            error_area.Attributes["class"] = "alert alert_info";

            if (count > 0)
            {
                SqlDataSource sds = DatabaseManager.CreateSQLDataSource("SELECT LEV_MAIN.LEAVE_ID รหัสการลา, (SELECT PERSON_NAME || ' ' || PERSON_LASTNAME FROM TB_PERSON WHERE CITIZEN_ID = LEV_MAIN.CITIZEN_ID) ชื่อผู้ลา, (SELECT LEAVE_TYPE_NAME FROM LEV_TYPE WHERE LEV_TYPE.LEAVE_TYPE_ID = LEV_MAIN.LEAVE_TYPE_ID) ประเภทการลา, LEV_MAIN.REQ_DATE วันที่ข้อมูล FROM LEV_MAIN, LEV_FORM1 WHERE LEV_MAIN.LEAVE_ID = LEV_FORM1.LEAVE_ID AND LEAVE_STATE = 1 AND CMD_LOW_ID = '" + loginPerson.CitizenID + "'");
                GridView1.DataSource = sds;
                GridView1.DataBind();

                Util.NormalizeGridViewDate(GridView1, 3);

                TableCell newHeader = new TableCell();
                newHeader.Text = "เลือก";
                GridView1.HeaderRow.Cells.Add(newHeader);

                for (int i = 0; i < GridView1.Rows.Count; ++i)
                {
                    string       id = GridView1.Rows[i].Cells[0].Text;
                    Form1Package f1 = DatabaseManager.GetForm1Package(id);

                    LinkButton lbu = new LinkButton();
                    lbu.Text     = "เลือก";
                    lbu.CssClass = "button button_default";
                    lbu.Click   += (e2, e3) => {
                        lbF1LeaveID.Text          = id;
                        lbF1LeaverName.Text       = f1.PersonPrefix + f1.PersonFirstName + " " + f1.PersonLastName;
                        lbF1PersonPosition.Text   = f1.PersonPosition;
                        lbF1PersonDepartment.Text = f1.PersonDepartment;
                        lbF1PersonRank.Text       = f1.PersonRank;
                        lbF1ReqDate.Text          = f1.RequestDate;
                        lbF1LeaveTypeName.Text    = f1.LeaveTypeName;
                        if (f1.LastFromDate == "")
                        {
                            lbF1LastFTTDate.Text = "ยังไม่เคยลา";
                        }
                        else
                        {
                            lbF1LastFTTDate.Text = f1.LastFromDate + " - " + f1.LastToDate + " / รวม " + f1.LastTotalDay + " วัน";
                        }
                        lbF1FTTDate.Text = f1.FromDate + " - " + f1.ToDate + " / รวม " + f1.TotalDay + " วัน";
                        lbF1Reason.Text  = f1.Reason;
                        lbF1Contact.Text = f1.Contact;
                        lbF1Phone.Text   = f1.Phone;

                        MultiView1.ActiveViewIndex = 1;

                        error_area.Attributes["class"] = "alert alert_info";
                        error_area.InnerHtml           = "กรุณาลงความเห็น";
                    };
                    TableCell cell = new TableCell();
                    cell.Controls.Add(lbu);
                    GridView1.Rows[i].Cells.Add(cell);
                }

                /*HTable htable = new HTable(i1);
                 * htable.AddHeaderRow(new string[] { "รหัสการลา", "วันที่ยื่นเรื่อง", "ผู้ลา", "ประเภทการลา", "เลือก" });
                 * using (OleDbConnection con = new OleDbConnection(DatabaseManager.CONNECTION_STRING)) {
                 *  con.Open();
                 *  using (OleDbCommand com = new OleDbCommand("SELECT LEV_MAIN.LEAVE_ID, REQ_DATE, (SELECT PERSON_NAME || ' ' || PERSON_LASTNAME FROM TB_PERSON WHERE CITIZEN_ID = LEV_MAIN.CITIZEN_ID), LEAVE_TYPE_NAME FROM LEV_MAIN, LEV_FORM1, LEV_TYPE WHERE LEV_MAIN.LEAVE_ID = LEV_FORM1.LEAVE_ID AND LEV_FORM1.CMD_LOW_ID = '" + loginPerson.CitizenID + "' AND LEV_MAIN.LEAVE_TYPE_ID = LEV_TYPE.LEAVE_TYPE_ID AND LEV_MAIN.LEAVE_STATE = 1", con)) {
                 *      using (OleDbDataReader reader = com.ExecuteReader()) {
                 *          while (reader.Read()) {
                 *
                 *              string id = reader.GetValue(0).ToString();
                 *              Form1Package f1 = DatabaseManager.GetForm1Package(id);
                 *              string req_date = Util.PureDatabaseToThaiDate(reader.GetValue(1).ToString());
                 *              string name = reader.GetValue(2).ToString();
                 *              string leave_type_name = reader.GetValue(3).ToString();
                 *              htable.AddRow(new string[] {
                 *              id,
                 *              req_date,
                 *              name,
                 *              leave_type_name,
                 *          });
                 *              LinkButton b = new LinkButton();
                 *              b.Text = "เลือก";
                 *              b.CssClass = "hm_button_primary";
                 *              b.Click += (e2, e3) => {
                 *                  lbF1LeaveID.Text = id;
                 *                  lbF1LeaverName.Text = name;
                 *
                 *                  lbF1PersonPosition.Text = f1.PersonPosition;
                 *                  lbF1PersonDepartment.Text = f1.PersonDepartment;
                 *                  lbF1PersonRank.Text = f1.PersonRank;
                 *                  lbF1ReqDate.Text = req_date;
                 *                  lbF1LeaveTypeName.Text = leave_type_name;
                 *                  if (f1.LastFromDate == "''") {
                 *                      lbF1LastFTTDate.Text = "ยังไม่เคยลา";
                 *                  } else {
                 *                      lbF1LastFTTDate.Text = f1.LastFromDate + " - " + f1.LastToDate + " / รวม " + f1.LastTotalDay + " วัน";
                 *                  }
                 *
                 *                  lbF1FTTDate.Text = f1.FromDate + " - " + f1.ToDate + " / รวม " + f1.TotalDay + " วัน";
                 *
                 *                  lbF1Reason.Text = f1.Reason;
                 *                  lbF1Contact.Text = f1.Contact;
                 *                  lbF1Phone.Text = f1.Phone;
                 *
                 *                  i1.Style.Add("display", "none");
                 *                  i2.Style.Add("display", "block");
                 *                  i3.Style.Add("display", "none");
                 *                  error_area.Attributes["class"] = "hm_alert_info";
                 *                  error_area.InnerHtml = "กรุณาลงความเห็น";
                 *              };
                 *              TableCell c = new TableCell();
                 *              c.Controls.Add(b);
                 *              htable.LastestRow().Cells.Add(c);
                 *          }
                 *      }
                 *  }
                 * }*/
            }
        }