Example #1
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() }));
        }
Example #2
0
        internal void Process()
        {
            dbHelper helper = new dbHelper();

            helper.UpdateMissedData();
            FillSettings();
            if (settings != null)
            {
                double timerInterval = 10;
                double.TryParse(settings["EmailSendInterval"], out timerInterval);
                int.TryParse(settings["ThreadCount"], out thread_count);

                if (timerInterval == 0)
                {
                    timerInterval = 0.1;
                }
                collection = new List <mailDetails>();

                emailerTimer          = new System.Timers.Timer();
                emailerTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetMail);

                emailerTimer.Interval  = 60000 * timerInterval;
                emailerTimer.Enabled   = true;
                emailerTimer.AutoReset = true;
                emailerTimer.Start();
            }
        }
Example #3
0
        protected void ButtonPlay_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (dt.Rows.Count > 0)
                {
                    Flows playflow = SaveFlow();
                    if (playflow != null)
                    {
                        FlowInstances currentFlow = new FlowInstances();
                        dbHelper helper = new dbHelper();
                        DataRow firstRow = dt.Rows[0];
                        Actions startAction = helper.GetActionById(firstRow["Id"].ToString());

                        currentFlow.Actions = startAction;
                        currentFlow.CurrentPosition = 1;
                        currentFlow.Users = playflow.Users;
                        currentFlow.Flows = playflow;
                        helper.AddToModel(currentFlow);

                        Session["currentInstance"] = currentFlow;
                        Server.Transfer(currentFlow.Actions.ActionPage);
                    }
                }
            }
        }
Example #4
0
        public void insertCar(dbHelper db)
        {
            Console.Write("Add new car:\n");
            Console.Write("id:\n");
            string id = Console.ReadLine();

            Console.Write("brand:\n");
            string brand = Console.ReadLine();

            Console.Write("model:\n");
            string model = Console.ReadLine();

            Console.Write("price:\n");
            int price;

            try
            {
                price = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception e)
            {
                price = 100;
            }
            Console.Write("location:\n");
            string location = Console.ReadLine();
            Car    car      = new Car();

            db.insertCar(id, brand, model, price, location, car);
            Console.Read();
            Console.Read();
        }
Example #5
0
        public void changeCar(dbHelper db)
        {
            Console.Write("Enter idCar for change:\n");
            string id = Console.ReadLine();

            db.selectCar(id);
            Console.Write("Enter new brand:\n");
            string brand = Console.ReadLine();

            Console.Write("Enter new model:\n");
            string model = Console.ReadLine();

            Console.Write("Enter new price:\n");
            int price;

            try
            {
                price = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception e)
            {
                price = 100;
            }
            Console.Write("Enter new location:\n");
            string location = Console.ReadLine();

            db.updateCar(id, brand, model, price, location);
            db.selectCar(id);
            Console.Read();
            Console.Read();
        }
Example #6
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 }));
        }
Example #7
0
 public userService(dbHelper context, IRepository <userModel> userService, IAddressService addressService, IMapper mapper)
 {
     _dbContext      = context;
     _userService    = userService;
     _addressService = addressService;
     _mapper         = mapper;
 }
Example #8
0
 public RentCar()
 {
     InitializeComponent();
     db = new dbHelper();
     db.openDb();
     totalPrice = 0;
 }
Example #9
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (Page.IsValid)
            {
                if (e.CommandName == "Select")
                {
                    Users newUser;
                    dbHelper helper = new dbHelper();
                    newUser = helper.GetUserbyName(TextBoxUser.Text);
                    if (newUser == null)
                    {
                        newUser = new Users();
                        newUser.UserName = TextBoxUser.Text;
                        newUser.UserType = "local";
                        newUser.SNUserId = "local" + TextBoxUser.Text;
                        helper.AddToModel(newUser);
                    }
                    Session["user"] = newUser;

                    WebControl wc = e.CommandSource as WebControl;
                    GridViewRow row = wc.NamingContainer as GridViewRow;
                    Session["UseCaseStartTime"] = DateTime.Now;
                    Session["UseCaseNumber"] = row.RowIndex + 1;
                    Session["UseCaseText"] = row.Cells[1].Text;

                    Server.Transfer("Design.aspx");
                }
            }
        }
Example #10
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"));
        }
Example #11
0
        public App(string dbPath)
        {
            InitializeComponent();

            dbHelper = new dbHelper(dbPath);

            MainPage = new NavigationPage(new MainPage());
        }
Example #12
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"));
        }
Example #13
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"));
        }
Example #14
0
        public void deleteCar(dbHelper db)
        {
            Console.Write("Car's brand for removing:\n");
            string brand = Console.ReadLine();

            db.deleteCar(brand);
            Console.Read();
            Console.Read();
        }
Example #15
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            dbHelper helper = new dbHelper();
            Users currentUser = new Users();
            currentUser = helper.GetTestUser();
            Session["user"] = currentUser;

            Server.Transfer("Design.aspx");
        }
Example #16
0
 public String GetActionOutput(String actionId)
 {
     dbHelper helper = new dbHelper();
     List<ActionOutputs> outputs = helper.GetActionOutputsForAction(actionId);
     if (outputs.Count > 0)
         return outputs[0].OutputObject;
     else
         return String.Empty;
 }
Example #17
0
        public Auth()
        {
            InitializeComponent();
            db = new dbHelper();
            db.openDb();

            passTextBox.MaxLength       = 8;
            passTextBox.PasswordChar    = '*';
            passTextBox.CharacterCasing = CharacterCasing.Lower;
        }
Example #18
0
File: User.cs Project: dina200/RC
        public void findCar(dbHelper db)
        {
            Console.Write("Car's brand:\n");
            string     brand = Console.ReadLine();
            List <Car> cars  = new List <Car> {
            };

            db.findCar(brand, cars);
            Console.Read();
            Console.Read();
        }
Example #19
0
        public Boolean isGMDep()
        {
            dbHelper dbh = new dbHelper();
            string   sql = @"select count(b.depNo) as cnt
                            from PoUsers a inner join jobPoes b on a.poNO=b.poNo 
                                           inner join deps c on b.depNo=c.depNo
                            where a.UserId='@workno' and a.applicationUser_id is not null and b.depNo='001'";

            sql = sql.Replace("@workno", this.emp.workNo);
            return(dbh.sql2count(sql) > 0);
        }
Example #20
0
File: User.cs Project: dina200/RC
        public void changeClientPhone(dbHelper db)
        {
            Console.Write("Client's passport:\n");
            string id = Console.ReadLine();

            Console.Write("New phone:\n");
            string phone = Console.ReadLine();

            db.changeClientDataPhone(id, phone);
            Console.Read();
            Console.Read();
        }
Example #21
0
        void updateDetails(mailDetails mail, bool Cancelled, Exception Error)
        {
            try
            {
                string error            = null;
                var    updateData       = mail.mail;
                int    int_failed_count = 0;
                if (updateData.int_failed_count != null)
                {
                    int_failed_count = updateData.int_failed_count.Value;
                }
                int int_satues = 0;
                if (!Cancelled && Error == null)
                {
                    updateData.dt_send_date = DateTime.Now;

                    int_satues = 255;
                }
                else
                {
                    int_satues = -1;

                    logHelper.LogException(Error, main_path);
                    if (Error != null)
                    {
                        if (Error.InnerException != null)
                        {
                            error = Error.InnerException.Message;
                        }
                        else
                        {
                            error = Error.Message;
                        }
                    }
                    int_failed_count++;
                }

                updateData.str_error        = error;
                updateData.int_status       = int_satues;
                updateData.int_failed_count = int_failed_count;

                dbHelper helper = new dbHelper();
                if (helper.UpdateData(updateData))
                {
                    collection.Remove(mail);
                }
            }

            catch (Exception er)
            {
                logHelper.LogException(er, main_path);
            }
        }
Example #22
0
 public Regist()
 {
     InitializeComponent();
     db = new dbHelper();
     db.openDb();
     passdRegTextBox.MaxLength          = 8;
     passdRegTextBox.PasswordChar       = '*';
     passdRegTextBox.CharacterCasing    = CharacterCasing.Lower;
     confPassRegTextBox.MaxLength       = 8;
     confPassRegTextBox.PasswordChar    = '*';
     confPassRegTextBox.CharacterCasing = CharacterCasing.Lower;
 }
Example #23
0
File: User.cs Project: dina200/RC
        public void changeCarLocation(dbHelper db)
        {
            Console.Write("Car's number:\n");
            string num = Console.ReadLine();

            Console.Write("New car's location:\n");
            string loc = Console.ReadLine();

            db.changeCarLocation(num, loc);
            Console.Read();
            Console.Read();
        }
Example #24
0
        private void WorkerThreadFunc()
        {
            if (settings != null && true)
            {
                dbHelper helper = new dbHelper();

                string smtpEmailAddress = settings["SMTPUserName"];
                string smtpPassword     = settings["SMTPPassword"];
                // string fromEmail = settings["FromEmail"];
                // string fromDisplayName = settings["FromDisplayName"];
                string smtpClientHost = settings["SMTPHostName"];
                int    smtoClientPort = int.Parse(settings["SMTPHostPort"]);
                bool   enableSsl = bool.Parse(settings["EnableSSL"]);
                bool   useDefaultCredentials = bool.Parse(settings["UseDefaultCredentials"]);
                int    emailForBulk = 50, reTryTime = 5;
                int.TryParse(settings["EmailForBulk"], out emailForBulk);
                int.TryParse(settings["ReTryTime"], out reTryTime);
                var databundle = helper.GetmailBulk(DateTime.Now, emailForBulk);

                var notsendbundle = helper.GetFailedBulk(reTryTime);
                if (databundle != null)
                {
                    databundle.AddRange(notsendbundle);
                }
                else
                {
                    databundle = notsendbundle;
                }
                if (databundle != null)
                {
                    helper.SetSettingFromKey("LastRunTime", DateTime.Now.ToString());
                    Parallel.ForEach(databundle, item =>
                    {
                        string newGuid = Guid.NewGuid().ToString();
                        var mail       = new mailDetails()
                        {
                            guid = newGuid, mail = item
                        };
                        collection.Add(mail);

                        sendEmail(mail, smtpEmailAddress, smtpPassword, smtpClientHost, smtoClientPort, enableSsl, useDefaultCredentials);
                    });
                }
            }

            current_thread_count--;
            if (!emailerTimer.Enabled)
            {
                emailerTimer.Start();
            }
        }
Example #25
0
File: User.cs Project: dina200/RC
 public void deleteRent(dbHelper db)
 {
     Console.Write("Rent's num:\n");
     try
     {
         int num = Convert.ToInt32(Console.ReadLine());
         db.deleteRent(num);
     }
     catch (Exception e)
     {
         Console.Write("Not corrct data:\n");
     }
     Console.Read();
     Console.Read();
 }
Example #26
0
File: User.cs Project: dina200/RC
        public void findCarById(dbHelper db)
        {
            Console.Write("Car's id:\n");
            string location = Console.ReadLine();
            Car    car      = db.findCar(location);

            if (car != null)
            {
                Console.Write(car.id + " " + car.location + "\n");
            }
            else
            {
                Console.Write("Car doesn't exist\n");
            }

            Console.Read();
            Console.Read();
        }
        protected void ButtonNext_Click(object sender, EventArgs e)
        {
            dbHelper helper = new dbHelper();
            FlowInstances currentFlow = (FlowInstances)Session["currentInstance"];
            Actions next = helper.GetNextAction(currentFlow.Flows.FlowId, currentFlow.CurrentPosition);
            if (next == null)
            {
                Server.Transfer("End.aspx");
            }
            else
            {
                FlowInstances flowInstance = helper.GetFlowInstanceById(currentFlow.FlowInstanceId);

                flowInstance.CurrentPosition++;
                flowInstance.Actions = next;
                helper.UpdateChanges();

                Session["currentInstance"] = flowInstance;
                Server.Transfer(flowInstance.Actions.ActionPage);
            }
        }
Example #28
0
File: User.cs Project: dina200/RC
        public void rentCar(dbHelper db)
        {
            string passport = Console.ReadLine();
            string fullName = Console.ReadLine();
            string phone    = Console.ReadLine();

            db.addClient(passport, fullName, phone);
            string carId = Console.ReadLine();
            int    duration;

            try
            {
                duration = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception e)
            {
                duration = 0;
            }
            string from = Console.ReadLine();
            string to   = Console.ReadLine();

            db.createRent(passport, carId, this, from, to, duration);
        }
Example #29
0
File: Auth.cs Project: dina200/RC
        private void authButton_Click(object sender, EventArgs e)
        {
            String login = loginTextBox.Text;
            String pass  = passTextBox.Text;
            User   user  = null;

            if (login.Equals("admin"))
            {
                user          = new Admin();
                user.login    = login;
                user.password = pass;
            }
            else
            {
                user          = new Manager();
                user.login    = login;
                user.password = pass;
            }
            if (db.getConn().State.ToString().Equals("Closed"))
            {
                db = new dbHelper();
                db.openDb();
            }
            if (db.authorisation(login, pass, user) != null)
            {
                user = db.authorisation(login, pass, user);
                new RentCar(user, this).Show();
                db.close();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Error! Not correct data");
                loginTextBox.Text = "";
                passTextBox.Text  = "";
            }
        }
        private void createActionTable(String actionType, DataTable dt)
        {
            dbHelper helper = new dbHelper();
            List<ActionInputs> actionsInput;
            List<ActionOutputs> actionsOutput;

            List<Actions> actionsType = helper.GetActionsByType(actionType);
            foreach (Actions itemAction in actionsType)
            {
                actionsInput = helper.GetActionInputsForAction(itemAction.ActionId);
                actionsOutput = helper.GetActionOutputsForAction(itemAction.ActionId);
                DataRow dr = dt.NewRow();
                if (actionsInput.Count > 0)
                    dr["Input"] = actionsInput[0].InputObject;
                else
                    dr["Input"] = String.Empty;
                dr["Name"] = itemAction.ActionName;
                if (actionsOutput.Count > 0)
                    dr["Output"] = actionsOutput[0].OutputObject;
                else
                    dr["Output"] = String.Empty;
                dt.Rows.Add(dr);
            }
        }
Example #31
0
        void FillSettings()
        {
            dbHelper helper                = new dbHelper();
            var      EmailSendInterval     = helper.GetSettingFromKey("EmailSendInterval", "10");
            var      EmailForBulk          = helper.GetSettingFromKey("EmailForBulk", "50");
            var      SMTPUserName          = helper.GetSettingFromKey("SMTPUserName", "");
            var      SMTPPassword          = helper.GetSettingFromKey("SMTPPassword", "");
            var      SMTPHostName          = helper.GetSettingFromKey("SMTPHostName", "");
            var      SMTPHostPort          = helper.GetSettingFromKey("SMTPHostPort", "");
            var      EnableSSL             = helper.GetSettingFromKey("EnableSSL", "true");
            var      LastRunTime           = helper.GetSettingFromKey("LastRunTime", "");
            var      ReTryTime             = helper.GetSettingFromKey("ReTryTime", "5");
            var      UseDefaultCredentials = helper.GetSettingFromKey("UseDefaultCredentials", "false");
            var      ThreadCount           = helper.GetSettingFromKey("ThreadCount", "1");

            if (ReTryTime != "" && EmailSendInterval != "" && EmailForBulk != "" && SMTPUserName != "" && SMTPPassword != "" && SMTPHostName != "" &&
                SMTPHostPort != "" && EnableSSL != "" && UseDefaultCredentials != "" && ThreadCount != "")
            {
                settings = new Dictionary <string, string>();
                settings.Add("EmailSendInterval", EmailSendInterval);
                settings.Add("EmailForBulk", EmailForBulk);
                settings.Add("SMTPUserName", SMTPUserName);
                settings.Add("SMTPPassword", SMTPPassword);
                settings.Add("SMTPHostName", SMTPHostName);
                settings.Add("SMTPHostPort", SMTPHostPort);
                settings.Add("EnableSSL", EnableSSL);
                settings.Add("LastRunTime", LastRunTime);
                settings.Add("ReTryTime", ReTryTime);
                settings.Add("ThreadCount", ThreadCount);
                settings.Add("UseDefaultCredentials", UseDefaultCredentials);
            }
            else
            {
                logHelper.LogException(new Exception("Settings are invalid"), main_path);
            }
        }
Example #32
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"));
     }
 }
Example #33
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"));
        }
Example #34
0
        public JsonResult Get()
        {
            dbHelper helper = new dbHelper();

            return(Json(helper.getTasks()));
        }
Example #35
0
        public ActionResult QueryReportA(string dt1, string dt2, string rdRpt)
        {
            dbHelper dbh = new dbHelper();

            if (rdRpt == "1")
            {
                ExcelPackage ep = new ExcelPackage();

                //建立第一個Sheet,後方為定義Sheet的名稱
                ExcelWorksheet sheet = ep.Workbook.Worksheets.Add("請假單總表");
                int            col   = 1;
                sheet.Cells[1, col++].Value = "申請日期";
                sheet.Cells[1, col++].Value = "簽核日期";
                sheet.Cells[1, col++].Value = "單號";
                sheet.Cells[1, col++].Value = "工號";
                sheet.Cells[1, col++].Value = "姓名";
                sheet.Cells[1, col++].Value = "開始日期";
                sheet.Cells[1, col++].Value = "結束日期";
                sheet.Cells[1, col++].Value = "假別";
                sheet.Cells[1, col++].Value = "時數";
                sheet.Cells[1, col++].Value = "代理人工號";
                sheet.Cells[1, col++].Value = "備註";

                DataTable tb1 = new DataTable();
                string    sql = string.Format(
                    @" select b.billdate,b.signDate, b.billno, b.senderNo, c.cname, a.dtBegin, a.dtEnd, a.dType, a.hours, a.jobAgent, a.sMemo from dayoffs a 
                        inner join flowmains b on a.flowid=b.id
                        left join AspNetUsers c on b.senderNo=c.workno
                        where b.billdate >='{0}' and b.billdate <= '{1}' and b.flowStatus=2 
                        order by b.billDate asc
                    ",
                    dt1, dt2
                    );
                tb1 = dbh.sql2tb(sql);
                int row = 2;
                foreach (DataRow r in tb1.Rows)
                {
                    sheet.Cells[row, 1].Style.Numberformat.Format = "yyyy/mm/dd";
                    sheet.Cells[row, 2].Style.Numberformat.Format = "yyyy/mm/dd";
                    sheet.Cells[row, 6].Style.Numberformat.Format = "yyyy/mm/dd HH:MM:ss";
                    sheet.Cells[row, 7].Style.Numberformat.Format = "yyyy/mm/dd HH:MM:ss";
                    sheet.Cells[row, 1].Value  = r[0];
                    sheet.Cells[row, 2].Value  = r[1];
                    sheet.Cells[row, 3].Value  = r[2];
                    sheet.Cells[row, 4].Value  = r[3];
                    sheet.Cells[row, 5].Value  = r[4];
                    sheet.Cells[row, 6].Value  = r[5];
                    sheet.Cells[row, 7].Value  = r[6];
                    sheet.Cells[row, 8].Value  = r[7];
                    sheet.Cells[row, 9].Value  = r[8];
                    sheet.Cells[row, 10].Value = r[9];
                    sheet.Cells[row, 11].Value = r[10];
                    row++;
                }
                for (col = 1; col < 12; col++)
                {
                    sheet.Column(col).AutoFit();
                }

                MemoryStream fileStream = new MemoryStream();
                ep.SaveAs(fileStream);
                ep.Dispose();            //如果這邊不下Dispose,建議此ep要用using包起來,但是要記得先將資料寫進MemoryStream在Dispose。
                fileStream.Position = 0; //不重新將位置設為0,excel開啟後會出現錯誤
                return(File(fileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "請假單總表" + ctx.getLocalTiime().ToString("yyyyMMddHHmmss") + ".xlsx"));
            }
            else
            {
                ExcelPackage ep = new ExcelPackage();

                //建立第一個Sheet,後方為定義Sheet的名稱
                ExcelWorksheet sheet = ep.Workbook.Worksheets.Add("加班單總表");
                int            col   = 1;
                sheet.Cells[1, col++].Value = "申請日期";
                sheet.Cells[1, col++].Value = "簽核日期";
                sheet.Cells[1, col++].Value = "單號";
                sheet.Cells[1, col++].Value = "工號";
                sheet.Cells[1, col++].Value = "姓名";
                sheet.Cells[1, col++].Value = "開始時間";
                sheet.Cells[1, col++].Value = "結束時間";
                sheet.Cells[1, col++].Value = "時數";
                sheet.Cells[1, col++].Value = "加班事由";


                DataTable tb1 = new DataTable();
                string    sql = string.Format(
                    @" SELECT b.billDate,b.signDate,b.billno,b.senderNo,c.cname,a.dtbegin,a.dtend,a.hours,a.smemo
                          FROM [seform].[dbo].[ReqOverTimes] a inner join flowmains b on a.flowid=b.id
                          left join AspNetUsers c on b.senderNo=c.workno
                          where b.billdate >= '{0}' and billdate<='{1}' and b.flowStatus=2  
                          and b.flowname=N'加班申請單'
                          order by b.billdate 
                    ",
                    dt1, dt2
                    );
                tb1 = dbh.sql2tb(sql);
                int row = 2;
                foreach (DataRow r in tb1.Rows)
                {
                    sheet.Cells[row, 1].Style.Numberformat.Format = "yyyy/mm/dd";
                    sheet.Cells[row, 2].Style.Numberformat.Format = "yyyy/mm/dd";
                    sheet.Cells[row, 6].Style.Numberformat.Format = "yyyy/mm/dd HH:MM:ss";
                    sheet.Cells[row, 7].Style.Numberformat.Format = "yyyy/mm/dd HH:MM:ss";
                    sheet.Cells[row, 1].Value = r[0];
                    sheet.Cells[row, 2].Value = r[1];
                    sheet.Cells[row, 3].Value = r[2];
                    sheet.Cells[row, 4].Value = r[3];
                    sheet.Cells[row, 5].Value = r[4];
                    sheet.Cells[row, 6].Value = r[5];
                    sheet.Cells[row, 7].Value = r[6];
                    sheet.Cells[row, 8].Value = r[7];
                    sheet.Cells[row, 9].Value = r[8];
                    row++;
                }
                for (col = 1; col < 9; col++)
                {
                    sheet.Column(col).AutoFit();
                }

                MemoryStream fileStream = new MemoryStream();
                ep.SaveAs(fileStream);
                ep.Dispose();
                fileStream.Position = 0;
                return(File(fileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "加班單總表" + ctx.getLocalTiime().ToString("yyyyMMddHHmmss") + ".xlsx"));
            }



            ViewBag.dt1   = dt1;
            ViewBag.dt2   = dt2;
            ViewBag.rdRpt = rdRpt;
            return(View());
        }
Example #36
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                dt = new DataTable();
                MakeDataTable();

                String lastNode = null;
                SetActionGrid(lastNode);

                dtOptions = new DataTable();
                MakeDataTableOptions();
                AddToDataTableOptions("Add Options...");
                BindGridOptions();

                dtImports = new DataTable();
                MakeDataTableImports();

                _listFlowActOpt = new List<FlowActionOptions>();
                _listFlowActInput = new List<FlowActionInputs>();
                _listFlowActOutput = new List<FlowActionOutputs>();
                _listActOpt = new List<ActionOptions>();
                _listFlowMultiOpt = new List<FlowMultiOptions>();

                if (!Object.ReferenceEquals(Session["user"], null))
                {
                    _user = (Users)Session["user"];
                }
                else
                {
                    dbHelper helper = new dbHelper();
                    _user = helper.GetTestUser();
                }

                if (!Object.ReferenceEquals(Session["UseCaseNumber"], null))
                {
                    _useCaseNumber = (int)Session["UseCaseNumber"];
                }
                else
                {
                    _useCaseNumber = 0;
                }
                if (!Object.ReferenceEquals(Session["UseCaseStartTime"], null))
                {
                    _useCaseStartTime = (DateTime)Session["UseCaseStartTime"];
                }
                else
                {
                    _useCaseStartTime = DateTime.Now;
                }
                if (!Object.ReferenceEquals(Session["UseCaseText"], null))
                {
                    LabelUseCaseTooltip.Text = (String)Session["UseCaseText"];
                }
                else
                {
                    LabelUseCaseTooltip.Text = "Implement a process that meet your needs. Give it a meaningful name when saving.";
                }
                //Panel1.Visible = false;
            }
            else
            {
                dt = (DataTable)ViewState["MainFlow"];
                dtOptions = (DataTable)ViewState["TableOptions"];
                dtImports = (DataTable)ViewState["DataImports"];
                _listFlowActOpt = (List<FlowActionOptions>)ViewState["FlowActionOptions"];
                _listFlowActInput = (List<FlowActionInputs>)ViewState["FlowActionInputs"];
                _listFlowActOutput = (List<FlowActionOutputs>)ViewState["FlowActionOutputs"];
                _listActOpt = (List<ActionOptions>)ViewState["ActionOptions"];
                _listFlowMultiOpt = (List<FlowMultiOptions>)ViewState["FlowMultiOptions"];

                _user = (Users)Session["user"];
                _useCaseNumber = (int)Session["UseCaseNumber"];
                _useCaseStartTime = (DateTime)Session["UseCaseStartTime"];
                //Panel1.Visible = false;
            }

            ViewState["MainFlow"] = dt;
            ViewState["TableOptions"] = dtOptions;
            ViewState["DataImports"] = dtImports;
            ViewState["FlowActionOptions"] = _listFlowActOpt;
            ViewState["FlowActionInputs"] = _listFlowActInput;
            ViewState["FlowActionOutputs"] = _listFlowActOutput;
            ViewState["ActionOptions"] = _listActOpt;
            ViewState["FlowMultiOptions"] = _listFlowMultiOpt;
            //String selectedId = GridView1.DataKeys[row.RowIndex].Value.ToString();
            Session["user"] = _user;
            Session["UseCaseNumber"] = _useCaseNumber;
            Session["UseCaseStartTime"] = _useCaseStartTime;
        }
Example #37
0
        private void LoadActionOptions(String actionId)
        {
            dbHelper helper = new dbHelper();
            _listActOpt.Clear();
            _listActOpt = helper.GetActionOptionsForAction(actionId);

            TextBox tx;
            CheckBox ck;
            RadioButtonList rd;
            DropDownList dd;

            if (MultiViewSpecific.GetActiveView() == ViewPostMessage)
                rd = RadioButtonListPostMessage;
            else
                rd = RadioButtonListPostComment;
            foreach (ActionOptions itemActOpt in _listActOpt)
            {
                if (itemActOpt.ControlName != null)
                {
                    switch (itemActOpt.Options.OptionType)
                    {
                        case "textbox":
                            tx = (TextBox)FindControl(itemActOpt.ControlName);
                            if (tx != null)
                            {
                                tx.Text = itemActOpt.DefaultValue;
                            }
                            break;
                        case "check":
                            ck = (CheckBox)FindControl(itemActOpt.ControlName);
                            if (ck != null)
                            {
                                if (itemActOpt.DefaultValue == "true")
                                    ck.Checked = true;
                                else
                                    ck.Checked = false;
                            }
                            break;
                        case "radio":
                            if (itemActOpt.DefaultValue == "true")
                                rd.SelectedValue = itemActOpt.ControlName;
                            break;
                        case "dropdown":
                            dd = (DropDownList)FindControl(itemActOpt.ControlName);
                            if (dd != null)
                            {
                                dd.SelectedValue = itemActOpt.DefaultValue;
                            }
                            break;
                    }
                }
            }
            ViewState["ActionOptions"] = _listActOpt;
        }
Example #38
0
        private void LoadPreviousActionOptions(String actionId)
        {
            dbHelper helper = new dbHelper();
            _listActOpt.Clear();
            _listActOpt = helper.GetActionOptionsForAction(actionId);

            ActionOptions itemActOpt;
            TextBox tx;
            CheckBox ck;
            RadioButtonList rd;
            DropDownList dd;

            if (MultiViewSpecific.GetActiveView() == ViewPostMessage)
                rd = RadioButtonListPostMessage;
            else
                rd = RadioButtonListPostComment;
            foreach (FlowActionOptions itemFlowActOpt in _listFlowActOpt)
            {
                if (itemFlowActOpt.FlowPosition == dt.Rows.Count)
                {
                    itemActOpt = itemFlowActOpt.ActionOptions;
                    if (itemActOpt.ControlName != null)
                    {
                        switch (itemActOpt.Options.OptionType)
                        {
                            case "textbox":
                                tx = (TextBox)FindControl(itemActOpt.ControlName);
                                if (tx != null)
                                {
                                    tx.Text = itemFlowActOpt.Value;
                                }
                                break;
                            case "check":
                                ck = (CheckBox)FindControl(itemActOpt.ControlName);
                                if (ck != null)
                                {
                                    if (itemFlowActOpt.Value == "true")
                                        ck.Checked = true;
                                    else
                                        ck.Checked = false;
                                }
                                break;
                            case "radio":
                                if (itemFlowActOpt.Value == "true")
                                    rd.SelectedValue = itemActOpt.ControlName;
                                if (itemActOpt.ControlName == "MultOptCom" && itemFlowActOpt.Value == "true")
                                {
                                    dtOptions.Clear();
                                    foreach (FlowMultiOptions itemFlowMultiOpt in _listFlowMultiOpt)
                                    {
                                        if (itemFlowMultiOpt.FlowPosition == dt.Rows.Count)
                                        {
                                            AddToDataTableOptions(itemFlowMultiOpt.OptionValue);
                                        }
                                    }
                                    BindGridOptions();
                                }

                                break;
                            case "dropdown":
                                dd = (DropDownList)FindControl(itemActOpt.ControlName);
                                if (dd != null)
                                {
                                    dd.SelectedValue = itemFlowActOpt.Value;
                                }
                                break;
                        }
                    }
                }
            }
            ViewState["ActionOptions"] = _listActOpt;
        }
Example #39
0
        private void SaveActionOptions(int position)
        {
            FlowActionOptions fao;
            FlowActionInputs faIn;
            FlowActionOutputs faOut;
            TextBox tx;
            CheckBox ck;
            RadioButtonList rd;
            DropDownList dd;
            _listFlowActOpt.RemoveAll(f => f.FlowPosition == position);
            _listFlowActInput.RemoveAll(f => f.FlowPosition == position);
            _listFlowActOutput.RemoveAll(f => f.FlowPosition == position);

            if (MultiViewSpecific.GetActiveView() == ViewPostMessage)
                rd = RadioButtonListPostMessage;
            else
                rd = RadioButtonListPostComment;
            foreach (ActionOptions itemActOpt in _listActOpt)
            {
                if (itemActOpt.ControlName != null)
                {
                    fao = new FlowActionOptions();
                    fao.ActionOptions = itemActOpt;
                    fao.FlowPosition = position;
                    switch (itemActOpt.Options.OptionType)
                    {
                        case "textbox":
                            tx = (TextBox)FindControl(itemActOpt.ControlName);
                            if (tx != null)
                            {
                                fao.Value = tx.Text;
                            }
                            break;
                        case "check":
                            ck = (CheckBox)FindControl(itemActOpt.ControlName);
                            if (ck != null)
                            {
                                if (ck.Checked)
                                    fao.Value = "true";
                                else
                                    fao.Value = "false";
                            }
                            break;
                        case "radio":
                            if (rd.SelectedValue == itemActOpt.ControlName)
                                fao.Value = "true";
                            else
                                fao.Value = "false";

                            if (itemActOpt.ControlName == "MultOptCom" && fao.Value == "true")
                            {
                                FlowMultiOptions fmo;
                                _listFlowMultiOpt.RemoveAll(fm => fm.FlowPosition == position);
                                foreach (DataRow itemMultiOpt in dtOptions.Rows)
                                {
                                    fmo = new FlowMultiOptions();
                                    fmo.FlowPosition = position;
                                    fmo.OptionValue = itemMultiOpt["Option"].ToString();
                                    _listFlowMultiOpt.Add(fmo);
                                }
                                if (dt.Rows.Count != position)
                                {
                                    dtOptions.Clear();
                                    AddToDataTableOptions("Add Options...");
                                    BindGridOptions();
                                }
                            }
                            break;
                        case "dropdown":
                            dd = (DropDownList)FindControl(itemActOpt.ControlName);
                            if (dd != null)
                            {
                                fao.Value = dd.SelectedValue;
                            }
                            break;
                    }
                    _listFlowActOpt.Add(fao);
                }
            }
            dbHelper helper = new dbHelper();
            if (dt.Rows[position - 1].Field<String>("Input") != String.Empty)
            {
                List<ActionInputs> inputs = helper.GetActionInputsForAction(dt.Rows[position - 1].Field<String>("Id"));
                faIn = new FlowActionInputs();
                faIn.FlowPosition = position;
                faIn.ActionInputs = inputs[0];
                faIn.Value = dt.Rows[position - 1].Field<String>("Input");
                _listFlowActInput.Add(faIn);
            }
            if (dt.Rows[position - 1].Field<String>("Output") != String.Empty)
            {
                List<ActionOutputs> outputs = helper.GetActionOutputsForAction(dt.Rows[position - 1].Field<String>("Id"));
                faOut = new FlowActionOutputs();
                faOut.FlowPosition = position;
                faOut.ActionOutputs = outputs[0];
                faOut.Value = dt.Rows[position - 1].Field<String>("Output");
                _listFlowActOutput.Add(faOut);
            }
        }
Example #40
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"));
        }
Example #41
0
        private Flows SaveFlow()
        {
            if (dt.Rows.Count <= 0)
            {
                return null;
            }
            dbHelper helper = new dbHelper();
            bool isUpdate = true;
            FlowActionOptions fao;
            FlowActionInputs faIn;
            FlowActionOutputs faOut;
            FlowMultiOptions fmo;
            ActionOptions actOpt;
            ActionInputs actInput;
            ActionOutputs actOutput;
            Users flowUser = helper.GetUserbyName(_user.UserName);
            Flows myflow = helper.GetFlowByName(TextBox1.Text, flowUser);
            if (myflow == null)
            {
                myflow = new Flows();
                myflow.FlowName = TextBox1.Text;
                myflow.Users = flowUser;
                myflow.FlowUseCaseNumber = _useCaseNumber;
                myflow.FlowStartTime = _useCaseStartTime;
                myflow.FlowEndTime = DateTime.Now;
                isUpdate = false;
            }
            else
            {
                myflow.FlowEndTime = DateTime.Now;
                helper.DeleteFlowDetailsById(myflow.FlowId);
            }

            int rowCount = 0;

            FlowActions flowAction;
            Actions curAction;
            foreach (DataRow gridRow in dt.Rows)
            {
                rowCount++;
                curAction = helper.GetActionById(gridRow["Id"].ToString());
                flowAction = new FlowActions();
                flowAction.Actions = curAction;
                flowAction.Position = rowCount;
                myflow.FlowActions.Add(flowAction);
            }

            SaveActionOptions(dt.Rows.Count);
            foreach (FlowActionOptions itemFlowActOpt in _listFlowActOpt)
            {
                fao = new FlowActionOptions();
                actOpt = helper.GetActionOptionById(itemFlowActOpt.ActionOptions.ActionOptionId);
                fao.ActionOptions = actOpt;
                fao.FlowPosition = itemFlowActOpt.FlowPosition;
                fao.Value = itemFlowActOpt.Value;
                myflow.FlowActionOptions.Add(fao);
            }
            foreach (FlowActionInputs itemFlowActIn in _listFlowActInput)
            {
                faIn = new FlowActionInputs();
                actInput = helper.GetActionInputById(itemFlowActIn.ActionInputs.InputId);
                faIn.ActionInputs = actInput;
                faIn.FlowPosition = itemFlowActIn.FlowPosition;
                faIn.Value = itemFlowActIn.Value;
                myflow.FlowActionInputs.Add(faIn);
            }
            foreach (FlowActionOutputs itemFlowActOut in _listFlowActOutput)
            {
                faOut = new FlowActionOutputs();
                actOutput = helper.GetActionOutputById(itemFlowActOut.ActionOutputs.OutputId);
                faOut.ActionOutputs = actOutput;
                faOut.FlowPosition = itemFlowActOut.FlowPosition;
                faOut.Value = itemFlowActOut.Value;
                myflow.FlowActionOutputs.Add(faOut);
            }

            foreach (FlowMultiOptions itemFlowMultiOpt in _listFlowMultiOpt)
            {
                fmo = new FlowMultiOptions();
                fmo.FlowPosition = itemFlowMultiOpt.FlowPosition;
                fmo.OptionValue = itemFlowMultiOpt.OptionValue;
                myflow.FlowMultiOptions.Add(fmo);
            }
            if (isUpdate)
            {
                helper.UpdateChanges();
            }
            else
            {
                helper.AddToModel(myflow);
            }

            return myflow;
        }
Example #42
0
 private void SetActionGrid(String LastNode)
 {
     String whereClause = String.Empty;
     dbHelper helper = new dbHelper();
     List<String> nextNodes = helper.GetNextNodes(LastNode);
     foreach (String itemNode in nextNodes)
     {
         whereClause += " it.[ActionId] = '" + itemNode + "' OR";
     }
     whereClause = whereClause.Substring(0, whereClause.Length - 2);
     SimpleFlowDS.Where = whereClause;
 }
Example #43
0
        private void InitializeApp()
        {
            dbHelper helper = new dbHelper();
            ApplicationInfo appInfo = helper.GetAppInfo();

            FacebookConnector fbApi = new FacebookConnector(appInfo.ApplicationURL, appInfo.ApplicationId, appInfo.RedirectURL, appInfo.ApplicationSecret, appInfo.PageId, appInfo.ApplicationAT, appInfo.PageOwnerId);
            Session["fbApi"] = fbApi;
        }