void CreateMode_Click(object sender, EventArgs args) { GenModel gen = new GenModel((ModelType)this.DataInfo); StringBuilder builder = new StringBuilder(); gen.Generate(builder); this.OnGenerate(this, builder); }
protected void btn_Export_Click(object sender, EventArgs e) { txtJoinDate = tb_BeginDate.Text; txtOutDate = tb_EndDate.Text; string currentPath = System.Web.HttpContext.Current.Server.MapPath("TravelFiles"); if (txtJoinDate != "" || txtOutDate != "") { //string sql = "select User_Name,USER_ID from Base_UserInfo where (join_date<='" + txtOutDate + "' and (out_date is null or out_date='1900-01-01' or out_date>='" + txtJoinDate + "'))"; //StringBuilder sb_sql = new StringBuilder(sql); //DataTable dt = DataFactory.SqlDataBase().GetPageList(sql, null, "User_Name", "asc", 1, 99999, ref count); DataTable dt = dtExport; GenModel GM = new GenModel(); string fn = txtJoinDate + "_" + txtOutDate + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "ATSReport.xls"; string SaveLocation = Server.MapPath("TravelFiles") + "\\" + fn; int intResult = GM.ExportExcel(dt, SaveLocation); //GM.rpExportExcel(ref rp_Item, fn, "application/ms-excel"); if (intResult != -1) { string fileName = fn; //客户端保存的文件名 string filePath = currentPath + "\\" + fileName;; //路径 FileInfo fileInfo = new FileInfo(filePath); fileName = Path.GetFileName(filePath); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.WriteFile(fileInfo.FullName); Response.Flush(); Response.End(); } } }
public ActionResult GetByTichurDates(TEBDData data) { DateTime to; string[] to_str = data.To.Split('/'); to = new DateTime(Int32.Parse(to_str[2]), Int32.Parse(to_str[0]), Int32.Parse(to_str[1])); DateTime from; string[] from_str = data.From.Split('/'); from = new DateTime(Int32.Parse(from_str[2]), Int32.Parse(from_str[0]), Int32.Parse(from_str[1])); if (from > to) { GenModel failRes = new GenModel(); failRes.data = new List <string[]>(); failRes.data.Add(new string[] { "טווח תאריכים אינו תקין" }); failRes.Status = "error"; return(Json(failRes)); } using (TimchurDatabaseEntities ent = new TimchurDatabaseEntities()) { GenModel Res = new GenModel(); Users use = ent.Users.Where(x => x.IDCardNumber == User.Identity.Name).First(); bool f = User.IsInRole("Admin"); string uni_fin = User.IsInRole("Admin") ? data.unit_field : use.UnitID.ToString(); int tem = 0; if (uni_fin != null) { tem = Int32.Parse(uni_fin); } int i; if (User.IsInRole("User")) { if (data.clu_field == null && data.auc_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else if (data.clu_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int al = Int32.Parse(data.auc_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.Clusetrs.AuctionID == al && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else if (data.auc_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int cl = Int32.Parse(data.clu_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.ClusterID == cl && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int al = Int32.Parse(data.auc_field); int cl = Int32.Parse(data.clu_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.Clusetrs.AuctionID == al && x.ClusterID == cl && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } } if (data.unit_field == null) { if (data.clu_field == null && data.auc_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else if (data.clu_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int al = Int32.Parse(data.auc_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.Clusetrs.AuctionID == al && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else if (data.auc_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int cl = Int32.Parse(data.clu_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.ClusterID == cl && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int al = Int32.Parse(data.auc_field); int cl = Int32.Parse(data.clu_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.Clusetrs.AuctionID == al && x.ClusterID == cl && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } } else { if (data.clu_field == null && data.auc_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else if (data.clu_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int al = Int32.Parse(data.auc_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.Clusetrs.AuctionID == al && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else if (data.auc_field == null) { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int cl = Int32.Parse(data.clu_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.ClusterID == cl && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } else { Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "", "", "", "", "", "", "", "", "" }); i = 0; int al = Int32.Parse(data.auc_field); int cl = Int32.Parse(data.clu_field); foreach (Tichurim tic in ent.Tichurim.Where(x => (f || x.StatusID == 1) && x.Clusetrs.AuctionID == al && x.ClusterID == cl && x.UnitID == tem && x.DateTimeCreated <to && x.DateTimeCreated> from).OrderBy(x => x.DateTimeCreated)) { Res.data.Add(new string[] { i.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, tic.DateTimeCreated.Value.ToString(), tic.Statuses.Name }); i++; } return(Json(Res)); } } } return(Json("")); }
public ActionResult GetByTichurNumber(TNData data) { using (TimchurDatabaseEntities ent = new TimchurDatabaseEntities()) { Users use = ent.Users.Where(x => x.IDCardNumber == User.Identity.Name).First(); bool f = User.IsInRole("Admin"); string uni_fin = User.IsInRole("Admin") ? data.unit_field : use.UnitID.ToString(); int tem = 0; if (uni_fin != null) { tem = Int32.Parse(uni_fin); } if (tem == 0 || ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && (f || x.StatusID == 1)).Count() == 0) { GenModel failRes = new GenModel(); failRes.data = new List <string[]>(); failRes.data.Add(new string[] { "תיחור אינו קיים בתוך השרת(או תחת היחידה הנתונה של המשתמש או שהוכנסה)" }); failRes.Status = "error"; return(Json(failRes)); } if (!User.IsInRole("User")) { if (data.unit_field == null) { GenModel failRes = new GenModel(); failRes.data = new List <string[]>(); failRes.data.Add(new string[] { "אנא בחר ערך בשדה יחידה" }); failRes.Status = "error"; return(Json(failRes)); } } Tichurim tic = ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && (f || x.StatusID == 1)).First(); if (ent.UnitsAuctions.Where(x => x.UnitID == tem && x.AuctionID == tic.Clusetrs.AuctionID).Count() > 0) { if (User.IsInRole("User")) { Cache.gen_lock.WaitOne(); ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && x.StatusID == 1).First().DateTimeSelected = DateTime.Now; ent.SaveChanges(); Cache.gen_lock.ReleaseMutex(); } tic = ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && (f || x.StatusID == 1)).First(); GenModel Res = new GenModel(); Res.Status = "K"; Res.data = new List <string[]>(); Res.data.Add(new string[] { "מספר שורה", "מס' בתוצאת שליפה", "יחידה", "מס' מכרז", "שם מכרז", "תיחור", "מספר סל", "שם סל", "שם ספק", "ח.פ", "איש קשר", "אימייל", "טלפון", "תאריך ושעה" }); int i = 0; foreach (SuppliersTichurim st in tic.SuppliersTichurim) { Suppliers sup = ent.Suppliers.Where(x => x.ID == st.SupplierID).First(); i++; Res.data.Add(new string[] { i.ToString(), st.PositionInList.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, sup.Name, sup.CompanyNumber, sup.ContactName, sup.EmailAddress, sup.PhoneNumber, tic.DateTimeCreated.Value.ToString() }); } return(Json(Res)); } else { GenModel failRes = new GenModel(); failRes.data = new List <string[]>(); failRes.data.Add(new string[] { "משתמש אינו רשאי לצפות בתיחור" }); failRes.Status = "error"; return(Json(failRes)); } } }
protected void Save_Click(object sender, EventArgs e) { string strNextApprover = ""; btnTravelDays_Click(null, null); 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_Error("Date Error"); } 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 (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["FilesAdd"] = txt_FilesAdd; ht["TravelDays"] = TravelDays.Text; int IsOk = DataFactory.SqlDataBase().InsertByHashtableReturnPkVal("Base_PerTravelApply", ht); if (IsOk > 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 (BLisAutoApproval(txt_NextApprover)) { string strsql = "select id from Base_PerTravelApply where EmpID='" + txt_EmpID + "' 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!"); } } }
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); }
protected void btn_MailTest_Click(object sender, EventArgs e) { GenModel gm = new GenModel(); string strMailResult = gm.SendMail2("*****@*****.**", "test", "test"); }
// Constructor public Session() { gmodel = new GenModel(); this._KV = 0; this._MAS = 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"); } }
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!"); } } } } } }