Ejemplo n.º 1
0
 protected void btn_submit_Click(object sender, EventArgs e)
 {
     if (FilesAdd.PostedFile != null && FilesAdd.PostedFile.ContentLength > 0)
     {
         //string fn = System.IO.Path.GetFileName(FileAdd.PostedFile.FileName);
         string fn           = string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now) + "_" + System.IO.Path.GetFileName(FilesAdd.PostedFile.FileName);
         string SaveLocation = Server.MapPath("LeaveFiles") + "\\" + fn;
         try
         {
             FilesAdd.PostedFile.SaveAs(SaveLocation);
             txt_FilesAdd = SaveLocation;
             //Response.Write("The file has been uploaded.");
             ShowMsgHelper.Alert("The file has been uploaded.");
         }
         catch (Exception ex)
         {
             //Response.Write("Error: " + ex.Message);
             ShowMsgHelper.Alert_Error("Error: " + ex.Message);
         }
     }
     else
     {
         //Response.Write("Please select a file to upload.");
         ShowMsgHelper.Alert_Wern("Please select a file to upload.");
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _key        = Request["key"];
            txt_EmpID   = RequestSession.GetSessionUser().UserId.ToString();
            txt_EmpName = RequestSession.GetSessionUser().UserName.ToString();

            if (!IsPostBack)
            {
                string        sql    = "select * from uvw_doLeaveDays where EmpID='" + txt_EmpID + "' ";
                StringBuilder sb_sql = new StringBuilder(sql);
                DataTable     dt     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sql);
                CJform.Visible = false;
                if (dt != null && dt.Rows.Count > 0)
                {
                    flo_njDays = float.Parse(dt.Rows[0].ItemArray[1].ToString());
                    flo_txDays = float.Parse(dt.Rows[0].ItemArray[2].ToString());
                }
                else
                {
                    flo_njDays = 0;
                    flo_txDays = 0;
                }

                if (!string.IsNullOrEmpty(_key))
                {
                    sql    = "select ApprovalFlag,FilesAdd from Base_PerLeaveApply where id='" + _key + "'";
                    sb_sql = new StringBuilder(sql);
                    dt     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sql);
                    if (dt.Rows[0].ItemArray[0] != null)
                    {
                        int_AppFlag = int.Parse(dt.Rows[0].ItemArray[0].ToString());
                        InitData();
                        if (int_AppFlag != 0 && int_AppFlag != 3)
                        {
                            Save.Visible = false;
                            ShowMsgHelper.Alert_Wern("Read Only!");
                        }
                        if (dt.Rows[0].ItemArray[1] == null || dt.Rows[0].ItemArray[1].ToString().Length == 0)
                        {
                            DownFiles.Visible = false;
                        }
                        else
                        {
                            DownFiles.Visible = true;
                            txt_downFilesAdd  = dt.Rows[0].ItemArray[1].ToString();
                        }
                    }
                    else
                    {
                        ShowMsgHelper.Alert_Wern("Data Error!");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void bind(string fileName)
        {
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                             "Data Source=" + fileName + ";" +
                             "Extended Properties='Excel 8.0; HDR=Yes; IMEX=1'";
            OleDbDataAdapter da = new OleDbDataAdapter("SELECT *  FROM [Sheet1$]", strConn);
            DataSet          ds = new DataSet();

            try
            {
                da.Fill(ds);
                dt = ds.Tables[0];
                this.GV_OriData.DataSource = dt;
                this.GV_OriData.DataBind();
                InsertToDB();
            }
            catch (Exception err)
            {
                ShowMsgHelper.Alert_Wern("Error!" + err.ToString());
            }
        }
Ejemplo n.º 4
0
        protected void Reject_Click(object sender, EventArgs e)
        {
            string txt_Remark    = "";
            int    int_AppStatus = 3;

            //if (txt_NextApprover == null || txt_NextApprover.Length <= 0)
            //{
            //    int_AppStatus = 2;
            //    txt_NextApprover = "";
            //}
            //else
            //{
            //    int_AppStatus = 1;
            //}

            string        sql1    = "update Base_PerLeaveApply set ApprovalFlag=" + int_AppStatus + " where id='" + _key + "' ";
            StringBuilder sb_sql1 = new StringBuilder(sql1);
            int           i1      = DataFactory.SqlDataBase().ExecuteBySql(sb_sql1);

            if (i1 > 0)
            {
                string Cur_Date = DateTime.Now.ToString("yyyy-MM-dd");
                string sql2     = "insert into Base_PerLeaveApplyDetail(PAid,ApproverId,ApprovalStatus,ApprovalRemark,ApprovalDate) ";
                sql2 = sql2 + "select " + _key + ",'" + txt_EmpID + "'," + int_AppStatus + ",'" + txt_Remark + "','" + Cur_Date + "' ";
                StringBuilder sb_sql2 = new StringBuilder(sql2);
                int           i2      = DataFactory.SqlDataBase().ExecuteBySql(sb_sql2);
                if (i2 > 0)
                {
                    ShowMsgHelper.AlertMsg("Success");
                }
                else
                {
                    ShowMsgHelper.Alert_Wern("Error");
                }
            }
            else
            {
                ShowMsgHelper.Alert_Wern("Error");
            }
        }
Ejemplo n.º 5
0
        protected void Save_Click(object sender, EventArgs e)
        {
            btnLeaveDays_Click(null, null);
            int intMaxPerTime = 9999;
            int intMaxPerYear = 9999;
            int intMustFile   = 0;

            String        yy              = DateTime.Now.Year.ToString();
            String        mm              = DateTime.Now.Month.ToString();
            String        days            = DateTime.DaysInMonth(int.Parse(yy), int.Parse(mm)).ToString();
            DateTime      FirstDay        = DateTime.Parse(yy + "/" + mm + "/1");
            DateTime      LastDay         = FirstDay.AddYears(1);
            float         floAllLeaveDays = 0;
            string        sqlii           = "select isnull(SUM(leavedays),0) as leavedays from Base_PerLeaveApply where EmpID='" + txt_EmpID + "' and LeaveID=" + LeaveID.SelectedValue + " and BeginDate>='" + FirstDay + "' and EndDate<'" + LastDay + "' and ApprovalFlag=2";
            StringBuilder sb_sqlii        = new StringBuilder(sqlii);
            DataTable     dtii            = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sqlii);

            if (dtii != null && dtii.Rows.Count > 0)
            {
                floAllLeaveDays = float.Parse(dtii.Rows[0].ItemArray[0].ToString());
            }

            string        sqli    = "select * from Base_ATS_LeaveSetting where id=" + LeaveID.SelectedValue;
            StringBuilder sb_sqli = new StringBuilder(sqli);
            DataTable     dti     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sqli);

            if (dti != null && dti.Rows.Count > 0)
            {
                if (int.Parse(dti.Rows[0].ItemArray[2].ToString()) > 0)
                {
                    intMaxPerTime = int.Parse(dti.Rows[0].ItemArray[2].ToString());
                }
                if (int.Parse(dti.Rows[0].ItemArray[3].ToString()) > 0)
                {
                    intMaxPerYear = int.Parse(dti.Rows[0].ItemArray[3].ToString());
                }
                if (int.Parse(dti.Rows[0].ItemArray[4].ToString()) > 0)
                {
                    intMustFile = int.Parse(dti.Rows[0].ItemArray[4].ToString());
                }
            }
            else
            {
                ShowMsgHelper.Alert_Error("System Error,Call Admin");
            }

            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy/MM/dd";
            if ((Convert.ToDateTime(BeginDate.Text, dtFormat) > Convert.ToDateTime(EndDate.Text, dtFormat)) || (Convert.ToDateTime(BeginDate.Text, dtFormat) == Convert.ToDateTime(EndDate.Text, dtFormat) && BeginFlag.Value == "0" && EndFlag.Value == "0"))
            {
                ShowMsgHelper.Alert_Wern("Date Error");
            }
            else
            {
                if (intMustFile == 1 && (txt_FilesAdd == null || txt_FilesAdd == ""))
                {
                    ShowMsgHelper.Alert_Wern("Must Upload the Proof Files!");
                }
                else
                {
                    if (float.Parse(LeaveDays.Text) > intMaxPerTime || floAllLeaveDays > intMaxPerYear)
                    {
                        ShowMsgHelper.Alert_Wern("Over the Limit!!");
                    }
                    else
                    {
                        if (LeaveID.SelectedValue == "7" && float.Parse(LeaveDays.Text) > float.Parse(njDays.Text))
                        {
                            ShowMsgHelper.Alert_Wern("Over the number of AL!");
                        }
                        else
                        {
                            Hashtable ht = new Hashtable();
                            ht = ControlBindHelper.GetWebControls(this.Page);
                            //ht["EmpID"] = txt_EmpID;
                            //ht["CreateDate"] = CreateDate.Text;
                            //ht["ApprovalFlag"] = 0;
                            if (int_AppFlag == 3)
                            {
                                ht["ApprovalFlag"] = 1;
                            }
                            //ht["NextApprover"] = txt_NextApprover;
                            ht["LeaveID"]   = LeaveID.SelectedValue;
                            ht["FilesAdd"]  = txt_FilesAdd;
                            ht["LeaveDays"] = LeaveDays.Text;
                            if (cbNC.Checked == true)
                            {
                                ht["NCJ"] = 1;
                            }
                            else
                            {
                                ht["NCJ"] = 0;
                            }
                            if (cbDBT.Checked == true)
                            {
                                ht["DBT"]    = 1;
                                ht["DBTnum"] = DBT.Text;
                            }
                            else
                            {
                                ht["DBT"]    = 0;
                                ht["DBTnum"] = 0;
                            }
                            int IsOk = DataFactory.SqlDataBase().UpdateByHashtable("Base_PerLeaveApply", "id", _key, ht);
                            if (IsOk > 0)
                            {
                                ShowMsgHelper.AlertMsg("Success!");
                            }
                            else
                            {
                                ShowMsgHelper.Alert_Error("Error!");
                            }
                        }
                    }
                }
            }
        }
        private string AutoApproval(string strApproverID, string _key)
        {
            string strResult        = "";
            string txt_NextApprover = "";
            //CallDays();
            string        sql1    = "select Boss_id from Base_UserInfo where user_id='" + strApproverID + "'";
            StringBuilder sb_sql1 = new StringBuilder(sql1);
            DataTable     dt1     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sql1);

            if (dt1.Rows[0].ItemArray[0] != null)
            {
                txt_NextApprover = dt1.Rows[0].ItemArray[0].ToString();
            }
            else
            {
                txt_NextApprover = "";
            }
            string txt_Remark    = "";
            int    int_AppStatus = 99;

            if (txt_NextApprover == null || txt_NextApprover.Length <= 0)
            {
                int_AppStatus    = 2;
                txt_NextApprover = "";
            }
            else
            {
                int_AppStatus = 1;
            }

            //txt_Remark = ApprovalRemark.InnerText;
            flotxDays = float.Parse(txDays.Text);

            sql1    = "update Base_PerTravelApply set ApprovalFlag=" + int_AppStatus + ",NextApprover='" + txt_NextApprover + "' where id='" + _key + "' ";
            sb_sql1 = new StringBuilder(sql1);
            int i1 = DataFactory.SqlDataBase().ExecuteBySql(sb_sql1);

            if (i1 > 0)
            {
                string Cur_Date = DateTime.Now.ToString("yyyy-MM-dd");
                string sql2     = "insert into Base_PerTravelApplyDetail(PTid,ApproverId,ApprovalStatus,ApprovalRemark,ApprovalDate) ";
                sql2 = sql2 + "select " + _key + ",'" + strApproverID + "'," + int_AppStatus + ",'" + txt_Remark + "','" + Cur_Date + "' ";
                StringBuilder sb_sql2 = new StringBuilder(sql2);
                int           i2      = DataFactory.SqlDataBase().ExecuteBySql(sb_sql2);
                if (i2 > 0)
                {
                    GenModel gm = new GenModel();
                    if (txt_NextApprover != null && txt_NextApprover != "" && gm.GetEMailFromID(txt_NextApprover) != "" && gm.GetEMailFromID(txt_NextApprover) != null)
                    {
                        gm.SendMail2(gm.GetEMailFromID(txt_NextApprover), "You have a new Task!", "You have a new Task!");
                    }
                    if (gm.GetEMailFromID(txt_EmpID) != null)
                    {
                        gm.SendMail2(gm.GetEMailFromID(txt_EmpID), "Your TraveList has been updated!", "Your TraveList has been updated!");
                    }
                    if (txt_NextApprover == null || txt_NextApprover == "")
                    {
                        string        sql3    = "update Base_LeaveConsole set SYTX=SYTX+" + flotxDays + " where EmpID='" + txt_EmpID + "' ";
                        StringBuilder sb_sql3 = new StringBuilder(sql3);
                        int           i3      = DataFactory.SqlDataBase().ExecuteBySql(sb_sql3);
                    }
                    ShowMsgHelper.AlertMsg("Success");
                }
                else
                {
                    ShowMsgHelper.Alert_Wern("Error");
                }
            }
            else
            {
                ShowMsgHelper.Alert_Wern("Error");
            }
            strResult = txt_NextApprover;
            return(strResult);
        }
Ejemplo n.º 7
0
        protected void Pass_Click(object sender, EventArgs e)
        {
            string txt_Remark    = "";
            int    int_AppStatus = 99;

            if (txt_NextApprover == null || txt_NextApprover.Length <= 0)
            {
                int_AppStatus    = 2;
                txt_NextApprover = "";
            }
            else
            {
                int_AppStatus = 1;
            }

            txt_Remark = ApprovalRemark.InnerText;

            string        sql1    = "update Base_PerLeaveApply set ApprovalFlag=" + int_AppStatus + ",NextApprover='" + txt_NextApprover + "' where id='" + _key + "' ";
            StringBuilder sb_sql1 = new StringBuilder(sql1);
            int           i1      = DataFactory.SqlDataBase().ExecuteBySql(sb_sql1);

            if (i1 > 0)
            {
                string Cur_Date = DateTime.Now.ToString("yyyy-MM-dd");
                string sql2     = "insert into Base_PerLeaveApplyDetail(PAid,ApproverId,ApprovalStatus,ApprovalRemark,ApprovalDate) ";
                sql2 = sql2 + "select " + _key + ",'" + txt_EmpID + "'," + int_AppStatus + ",'" + txt_Remark + "','" + Cur_Date + "' ";
                StringBuilder sb_sql2 = new StringBuilder(sql2);
                int           i2      = DataFactory.SqlDataBase().ExecuteBySql(sb_sql2);
                if (i2 > 0)
                {
                    GenModel gm = new GenModel();
                    if (txt_NextApprover != null && txt_NextApprover != "" && gm.GetEMailFromID(txt_NextApprover) != "" && gm.GetEMailFromID(txt_NextApprover) != null)
                    {
                        gm.SendMail2(gm.GetEMailFromID(txt_NextApprover), "You have a new Task!", "You have a new Task!");
                    }
                    if (gm.GetEMailFromID(strUserID) != null)
                    {
                        gm.SendMail2(gm.GetEMailFromID(strUserID), "Your LeaveList has been updated!", "Your LeaveList has been updated!");
                    }
                    if (txt_NextApprover == null || txt_NextApprover == "")
                    {
                    }
                    else
                    {
                        //string strNextApprover = AutoApproval(txt_NextApprover, _key);
                        string strNextApprover = txt_NextApprover;
                        while (BLisAutoApproval(strNextApprover))
                        {
                            strNextApprover = AutoApproval(strNextApprover, _key);
                        }
                    }
                    ShowMsgHelper.AlertMsg("Success");
                }
                else
                {
                    ShowMsgHelper.Alert_Wern("Error");
                }
            }
            else
            {
                ShowMsgHelper.Alert_Wern("Error");
            }
        }
Ejemplo n.º 8
0
        protected void Save_Click(object sender, EventArgs e)
        {
            btnLeaveDays_Click(null, null);
            int    intMaxPerTime   = 9999;
            int    intMaxPerYear   = 9999;
            int    intMustFile     = 0;
            string strNextApprover = "";

            String        yy              = DateTime.Now.Year.ToString();
            String        mm              = DateTime.Now.Month.ToString();
            String        days            = DateTime.DaysInMonth(int.Parse(yy), int.Parse(mm)).ToString();
            DateTime      FirstDay        = DateTime.Parse(yy + "/" + mm + "/1");
            DateTime      LastDay         = FirstDay.AddYears(1);
            float         floAllLeaveDays = 0;
            string        sqlii           = "select isnull(SUM(leavedays),0) as leavedays from Base_PerLeaveApply where EmpID='" + txt_EmpID + "' and LeaveID=" + LeaveID.SelectedValue + " and BeginDate>='" + FirstDay + "' and EndDate<'" + LastDay + "' and ApprovalFlag=2";
            StringBuilder sb_sqlii        = new StringBuilder(sqlii);
            DataTable     dtii            = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sqlii);

            if (dtii != null && dtii.Rows.Count > 0)
            {
                floAllLeaveDays = float.Parse(dtii.Rows[0].ItemArray[0].ToString());
            }

            string        sqli    = "select * from Base_ATS_LeaveSetting where id=" + LeaveID.SelectedValue;
            StringBuilder sb_sqli = new StringBuilder(sqli);
            DataTable     dti     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sqli);

            if (dti != null && dti.Rows.Count > 0)
            {
                if (int.Parse(dti.Rows[0].ItemArray[2].ToString()) > 0)
                {
                    intMaxPerTime = int.Parse(dti.Rows[0].ItemArray[2].ToString());
                }
                if (int.Parse(dti.Rows[0].ItemArray[3].ToString()) > 0)
                {
                    intMaxPerYear = int.Parse(dti.Rows[0].ItemArray[3].ToString());
                }
                if (int.Parse(dti.Rows[0].ItemArray[4].ToString()) > 0)
                {
                    intMustFile = int.Parse(dti.Rows[0].ItemArray[4].ToString());
                }
            }
            else
            {
                ShowMsgHelper.Alert_Error("System Error,Call Admin");
            }

            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy/MM/dd";
            if ((Convert.ToDateTime(BeginDate.Text, dtFormat) > Convert.ToDateTime(EndDate.Text, dtFormat)) || (Convert.ToDateTime(BeginDate.Text, dtFormat) == Convert.ToDateTime(EndDate.Text, dtFormat) && BeginFlag.Value == "0" && EndFlag.Value == "0"))
            {
                ShowMsgHelper.Alert_Wern("Date Error");
            }
            else
            {
                if (intMustFile == 1 && (txt_FilesAdd == null || txt_FilesAdd == ""))
                {
                    ShowMsgHelper.Alert_Wern("Must Upload the Proof Files!");
                }
                else
                {
                    if (float.Parse(LeaveDays.Text) > intMaxPerTime || floAllLeaveDays > intMaxPerYear)
                    {
                        ShowMsgHelper.Alert_Wern("Over the Limit!");
                    }
                    else
                    {
                        if (LeaveID.SelectedValue == "7" && float.Parse(LeaveDays.Text) > float.Parse(njDays.Text))
                        {
                            ShowMsgHelper.Alert_Wern("Over the number of AL!");
                        }
                        else
                        {
                            string        txt_NextApprover = "";
                            string        sql    = "select Boss_id from Base_UserInfo where user_id='" + txt_EmpID + "'";
                            StringBuilder sb_sql = new StringBuilder(sql);
                            DataTable     dt     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sql);
                            if (strHRid != "0000")
                            {
                                txt_NextApprover = strHRid;
                            }
                            else
                            {
                                if (dt.Rows[0].ItemArray[0] != null)
                                {
                                    txt_NextApprover = dt.Rows[0].ItemArray[0].ToString();;
                                }
                            }
                            Hashtable ht = new Hashtable();
                            ht                 = ControlBindHelper.GetWebControls(this.Page);
                            ht["EmpID"]        = txt_EmpID;
                            ht["CreateDate"]   = CreateDate.Text;
                            ht["ApprovalFlag"] = 0;
                            ht["NextApprover"] = txt_NextApprover;
                            ht["LeaveID"]      = LeaveID.SelectedValue;
                            ht["FilesAdd"]     = txt_FilesAdd;
                            ht["LeaveDays"]    = LeaveDays.Text;
                            if (cbNC.Checked == true)
                            {
                                ht["NCJ"] = 1;
                            }
                            else
                            {
                                ht["NCJ"] = 0;
                            }
                            if (cbDBT.Checked == true)
                            {
                                ht["DBT"]    = 1;
                                ht["DBTnum"] = DBT.Text;
                            }
                            else
                            {
                                ht["DBT"]    = 0;
                                ht["DBTnum"] = 0;
                            }
                            int IsOk = DataFactory.SqlDataBase().InsertByHashtableReturnPkVal("Base_PerLeaveApply", ht);
                            if (IsOk > 0)
                            {
                                //GenModel gm = new GenModel();
                                //string strMailResult = gm.SendMail("*****@*****.**", "*****@*****.**", "MailTest", "MailTest");
                                //if (strMailResult != "发送成功!")
                                //{
                                //    ShowMsgHelper.AlertMsg(strMailResult);
                                //}
                                GenModel gm = new GenModel();
                                if (txt_NextApprover != null && txt_NextApprover != "" && gm.GetEMailFromID(txt_NextApprover) != "" && gm.GetEMailFromID(txt_NextApprover) != null)
                                {
                                    gm.SendMail2(gm.GetEMailFromID(txt_NextApprover), "You have a new Task!", "You have a new Task!");
                                }
                                if (gm.GetEMailFromID(txt_EmpID) != null)
                                {
                                    gm.SendMail2(gm.GetEMailFromID(txt_EmpID), "Your LeaveList has been updated!", "Your LeaveList has been updated!");
                                }

                                if (BLisAutoApproval(txt_NextApprover))
                                {
                                    string        strsql = "select id from Base_PerLeaveApply where EmpID='" + txt_EmpID + "' and LeaveID='" + LeaveID.SelectedValue + "' and BeginDate='" + BeginDate.Text + "' and EndDate='" + EndDate.Text + "' and CreateDate='" + CreateDate.Text + "' ";
                                    StringBuilder sbsql  = new StringBuilder(strsql);
                                    DataTable     dtsql  = DataFactory.SqlDataBase().GetDataTableBySQL(sbsql);
                                    string        strid  = dtsql.Rows[0].ItemArray[0].ToString();
                                    strNextApprover = AutoApproval(txt_NextApprover, strid);
                                    while (BLisAutoApproval(strNextApprover))
                                    {
                                        strNextApprover = AutoApproval(strNextApprover, strid);
                                    }
                                }

                                ShowMsgHelper.AlertMsg("Success!");
                            }
                            else
                            {
                                ShowMsgHelper.Alert_Error("Error!");
                            }
                        }
                    }
                }
            }
        }