示例#1
0
        public ActionResult SaveList(int year, List <vwDayOffSum> data)
        {
            dbHelper dbh = new dbHelper();


            DataTable tb = new DataTable();

            tb = dbh.sql2tb("select workNo,m,v1 from dayOffSums where y = " + year.ToString() + " and sType='a'");

            List <string> sqlList = new List <string>();

            foreach (vwDayOffSum item in data)
            {
                List <decimal> vlist = new List <decimal>();
                vlist.Add(item.m0a);
                vlist.Add(item.m1a); vlist.Add(item.m2a); vlist.Add(item.m3a);
                vlist.Add(item.m4a); vlist.Add(item.m5a); vlist.Add(item.m6a);
                vlist.Add(item.m7a); vlist.Add(item.m8a); vlist.Add(item.m9a);
                vlist.Add(item.m10a); vlist.Add(item.m11a); vlist.Add(item.m12a);



                for (int i = 0; i < vlist.Count; i++)
                {
                    foreach (DataRow row in tb.Rows)
                    {
                        if (row["workNo"].ToString() == item.workNo &&
                            row["m"].ToString() == i.ToString() &&
                            ((Convert.ToDecimal(row["v1"]) - vlist[i]) != 0)
                            )
                        {
                            sqlList.Add(
                                string.Format(
                                    "update dayOffSums set v1 = {0} where y = {1} and m = {2} and sType = 'a' and workNo = '{3}';",
                                    vlist[i], year, i, item.workNo
                                    )
                                );
                            break;
                        }

                        if (sqlList.Count == 10)
                        {
                            dbh.execSql(string.Join(" ", sqlList));
                            sqlList.Clear();
                        }
                    }
                }
            }
            if (sqlList.Count > 0)
            {
                dbh.execSql(string.Join(" ", sqlList));
            }


            dynamic r = new ExpandoObject();

            r.success = true;
            return(Content(JsonConvert.SerializeObject(r), "application /json"));
        }
示例#2
0
        public ActionResult Delete(string hid)
        {
            dbHelper dbh = new dbHelper();

            dbh.execSql("delete from jobpoes where depNo='" + hid + "'");
            dbh.execSql("delete from deps where depNo='" + hid + "'");
            //dbh.execSql("delete from PoUsers where poNo in (select poNo from jobPoes)");
            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult DeletePo(string id)
        {
            dbHelper dbq = new dbHelper();

            dbq.execSql("delete from jobPoes where poNo='" + id + "'");
            return(RedirectToAction("Details", "Dep", new { id = Request["depNo"].ToString() }));
        }
示例#4
0
        public ActionResult DeleteSub(string hid, string hpid)
        {
            dbHelper dbh = new dbHelper();

            dbh.execSql("delete from FlowDefSub where id='" + hid + "'");
            return(RedirectToAction("SetupFlow", new { id = hpid }));
        }
示例#5
0
        public ActionResult Delete(string id)
        {
            dbHelper dbh = new dbHelper();

            dbh.execSql("update dbo.AspNetUsers set status=0,workNo=workNo+'-remove' where Id='" + id + "'");

            return(RedirectToAction("Index"));
        }
示例#6
0
        public ActionResult Delete(string id)
        {
            dbHelper dbh = new dbHelper();

            string filepath = dbh.sql2Str("select fileUrl from news where id='" + id + "'");

            try
            {
                DirectoryInfo di = new DirectoryInfo(@"C:\inetpub\upload\" + id);
                while (di.GetFiles().Count() > 0)
                {
                    di.GetFiles()[0].Delete();
                }
                di.Delete();
            }
            catch (Exception ex)
            {
                string exs = ex.Message;
            }

            dbh.execSql("delete from news where id='" + id + "'");

            return(RedirectToAction("Index"));
        }
示例#7
0
 public ActionResult Delete(FormCollection formCollection)
 {
     try
     {
         string[] ids = formCollection["ID"].Split(new char[] { ',' });
         if (ids.Count() == 0)
         {
             return(RedirectToAction("ListAll"));
         }
         List <string> idList = new List <string>();
         foreach (string s in ids)
         {
             idList.Add("'" + s + "'");
         }
         string   instr = string.Join(",", idList);
         dbHelper dbh   = new dbHelper();
         dbh.execSql("update flowmains set flowStatus=99 where id in (" + instr + ")");
         return(RedirectToAction("ListAll"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ListAll"));
     }
 }
示例#8
0
        public ActionResult Create(news model)
        {
            if (string.IsNullOrEmpty(model.newsType))
            {
                initNewsTypeList("");
                ModelState.AddModelError("newsType", "請選擇公告類別");
                return(View(model));
            }

            if (!ModelState.IsValid)
            {
                initNewsTypeList(model.newsType);
                return(View(model));
            }

            var context = new ApplicationDbContext();

            string ModelID = "";

            if (string.IsNullOrEmpty(model.id))
            {
                model.id          = Guid.NewGuid().ToString();
                ModelID           = model.id;
                model.createTime2 = context.getLocalTiime();
                //if (fileUrl != "")
                //{
                //    model.fileUrl = fileUrl;
                //}
                context.newsList.Add(model);
            }
            else
            {
                news currentModel = context.newsList.Where(x => x.id == model.id).FirstOrDefault();
                ModelID                 = currentModel.id;
                currentModel.title      = model.title;
                currentModel.createTime = DateTime.UtcNow.AddSeconds(28800);
                model.createTime2       = context.getLocalTiime();
                currentModel.content    = model.content;
                currentModel.ndate      = model.ndate;
                currentModel.newsType   = model.newsType;
                //if (fileUrl != "")
                //{
                //    currentModel.fileUrl = fileUrl;
                //}
            }

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                ModelState.AddModelError("", ex.Message);
                return(View());
            }

            dbHelper dbh = new dbHelper();

            string sfilelist = dbh.sql2Str("select fileUrl from news where id='" + ModelID + "'");
            JArray jlist     = new JArray();

            try
            {
                jlist = JArray.Parse(sfilelist);
            }
            catch (Exception ex)
            {
                jlist = new JArray();
            }


            for (int idx = 0; idx < Request.Files.Count; idx++)
            {
                var file = Request.Files[idx];
                if (file == null)
                {
                    continue;
                }
                if (file.ContentLength > 0)
                {
                    string originFileName = file.FileName;
                    string filename       = file.FileName.Replace("%", "").Replace(" ", "_");
                    string fileUrl        = ModelID + @"/" + filename;

                    var           path = @"C:\inetpub\upload\" + ModelID + @"\";
                    DirectoryInfo di   = new DirectoryInfo(path);
                    if (di.Exists == false)
                    {
                        di.Create();
                    }
                    path = path + @"\" + filename;
                    try
                    {
                        file.SaveAs(path);
                        JObject fileObj = new JObject();
                        fileObj["fileName"] = originFileName;
                        fileObj["fileUrl"]  = ModelID + @"\" + filename;
                        jlist.Add(fileObj);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            dbh.execSql("update news set fileUrl=N'" + jlist.ToString() + "' where id='" + ModelID + "'");

            return(RedirectToAction("Index"));
        }
示例#9
0
        public static bool doMigrate(DbMigrationsConfiguration config)
        {
            var  migrator           = new DbMigrator(config);
            bool _pendingMigrations = migrator.GetPendingMigrations().Any();

            // If there are pending migrations run migrator.Update() to create/update the database then run the Seed() method to populate
            //  the data if necessary
            if (_pendingMigrations)
            {
                migrator.Update();
                var context = new Models.ApplicationDbContext();
                importDefaultRole(context);
                importDefaultAdmin(context);

                dbHelper dbh = new dbHelper();
                dbh.execSql("update deps set sort=1 where sort=null");

                if (context.newsTypeList.Count() == 0)
                {
                    seedingNewsTypeList(context);
                }

                if (context.dayOffTypeList.Count() == 0)
                {
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 1, v = "事假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 2, v = "家庭照顧假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 3, v = "普通傷病假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 4, v = "生理假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 5, v = "公傷病假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 6, v = "婚假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 7, v = "喪假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 8, v = "陪產假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 9, v = "產檢假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 10, v = "產假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 11, v = "安胎假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 12, v = "公假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 13, v = "特別休假"
                    });
                    context.dayOffTypeList.Add(new dayOffType {
                        k = 14, v = "補休"
                    });
                    context.SaveChanges();
                }

                createFlowDef(context);
                createPermMod(context);
            }
            return(true);
        }
示例#10
0
        public ActionResult SignIt(FormCollection collection)
        {
            var    context   = new ApplicationDbContext();
            string id        = collection["hid"].ToString();
            string signValue = collection["signValue"].ToString();
            string signMemo  = collection["signMemo"].ToString();
            string workNo    = context.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault().workNo;

            FlowSub  fsub     = context.FlowSubList.Where(x => x.pid == id && x.workNo == workNo && x.signType != 701).FirstOrDefault();
            FlowMain fmain    = ctx.FlowMainList.Where(x => x.id == id).FirstOrDefault();
            bool     bIsGmDep = false;

            bIsGmDep = isGmDep(workNo);
            if (fsub != null && fmain != null)
            {
                if (fmain.defId == "OverTime")
                {
                    fsub.signDate   = context.getLocalTiime();
                    fsub.signResult = Convert.ToInt16(signValue);
                    fsub.comment    = signMemo;
                    context.SaveChanges();

                    dbHelper dbh = new dbHelper();
                    if (fsub.signResult == 1)
                    {
                        dbh.execSql("update FlowMains set flowStatus=2 where id='" + id + "'");
                    }

                    if (fsub.signResult == 2)
                    {
                        dbh.execSql("update FlowMains set flowStatus=3 where id='" + id + "'");
                    }
                }
                if (fmain.defId == "RealOverTime")
                {
                    if (fsub.signType != 3 && (!bIsGmDep))
                    {
                        List <FlowSub> qPriorSigner = ctx.FlowSubList.Where(x => x.pid == id && x.signType != 701 && x.seq < fsub.seq && x.signResult == 0).ToList <FlowSub>();
                        if (qPriorSigner.Count() > 0)
                        {
                            TempData["error"] = "上一位簽核人尚未簽核";
                            return(RedirectToAction("Details", "FormMgr", new { id = fmain.id }));
                        }
                    }
                    fsub.signDate   = context.getLocalTiime();
                    fsub.signResult = Convert.ToInt16(signValue);
                    fsub.comment    = signMemo;
                    context.SaveChanges();

                    dbHelper dbh      = new dbHelper();
                    var      fsublist = ctx.FlowSubList.Where(x => x.pid == id && x.signType != 701);
                    if (fsub.signResult == 1 &&
                        (fsublist.Where(x => x.signResult == 1).Count() == fsublist.Count() || bIsGmDep)
                        )
                    {
                        dbh.execSql("update FlowMains set flowStatus=2 where id='" + id + "'");
                    }

                    if (fsub.signResult == 2)
                    {
                        dbh.execSql("update FlowMains set flowStatus=3 where id='" + id + "'");
                    }
                }
                if (fmain.defId == "DayOff")
                {
                    if (fsub.signType != 3 && (!bIsGmDep))
                    {
                        List <FlowSub> qPriorSigner = ctx.FlowSubList.Where(x => x.pid == id && x.signType != 701 && x.seq < fsub.seq && x.signResult == 0).ToList <FlowSub>();
                        if (qPriorSigner.Count() > 0)
                        {
                            TempData["error"] = "上一位簽核人尚未簽核";
                            return(RedirectToAction("Details", "FormMgr", new { id = fmain.id }));
                        }
                    }
                    fsub.signDate   = context.getLocalTiime();
                    fsub.signResult = Convert.ToInt16(signValue);
                    fsub.comment    = signMemo;
                    context.SaveChanges();

                    dbHelper dbh      = new dbHelper();
                    var      fsublist = ctx.FlowSubList.Where(x => x.pid == id && x.signType != 701);
                    if (fsub.signResult == 1 &&
                        (fsublist.Where(x => x.signResult == 1).Count() == fsublist.Count() || bIsGmDep)
                        )
                    {
                        dbh.execSql("update FlowMains set flowStatus=2 where id='" + id + "'");
                    }

                    if (fsub.signResult == 2)
                    {
                        dbh.execSql("update FlowMains set flowStatus=3 where id='" + id + "'");
                    }
                }
                if (fmain.defId == "PublicOut")
                {
                    fsub.signDate   = context.getLocalTiime();
                    fsub.signResult = Convert.ToInt16(signValue);
                    fsub.comment    = signMemo;
                    context.SaveChanges();

                    dbHelper dbh = new dbHelper();
                    if (fsub.signResult == 1)
                    {
                        dbh.execSql("update FlowMains set flowStatus=2 where id='" + id + "'");
                    }

                    if (fsub.signResult == 2)
                    {
                        dbh.execSql("update FlowMains set flowStatus=3 where id='" + id + "'");
                    }
                }
                if (fmain.defId == "GuestForm")
                {
                    fsub.signDate   = context.getLocalTiime();
                    fsub.signResult = Convert.ToInt16(signValue);
                    fsub.comment    = signMemo;
                    context.SaveChanges();

                    dbHelper dbh = new dbHelper();
                    if (fsub.signResult == 1)
                    {
                        dbh.execSql("update FlowMains set flowStatus=2 where id='" + id + "'");
                    }

                    if (fsub.signResult == 2)
                    {
                        dbh.execSql("update FlowMains set flowStatus=3 where id='" + id + "'");
                    }
                }

                if (fmain.defId == "ReqInHouse")
                {
                    fsub.signDate   = context.getLocalTiime();
                    fsub.signResult = Convert.ToInt16(signValue);
                    fsub.comment    = signMemo;
                    context.SaveChanges();

                    dbHelper dbh = new dbHelper();
                    if (fsub.signResult == 1)
                    {
                        dbh.execSql("update FlowMains set flowStatus=2 where id='" + id + "'");
                    }

                    if (fsub.signResult == 2)
                    {
                        dbh.execSql("update FlowMains set flowStatus=3 where id='" + id + "'");
                    }
                }

                if (fsub.signResult == 1)
                {
                    dbHelper dbh = new dbHelper();
                    try
                    {
                        dbh.execSql("update FlowMains set signDate='" + ctx.getLocalTiime().ToString("yyyy-MM-dd HH:mm:ss") + "' where id='" + id + "'");
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            return(RedirectToAction("Index", "FormMgr"));
        }