Example #1
0
        public ActionResult std_half_day(std_halfday_log std)
        {
            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                string query = @"SELECT 
                                gate_pass_no, session
                            FROM
                                std_halfday_log
                            WHERE
                                sr_number = @sr_number
                                    AND DATE(date_time) = CURDATE()";

                std_halfday_log duplicategatepass = con.Query <std_halfday_log>(query, new { sr_number = std.sr_number }).SingleOrDefault();

                ExcelGatePassMain gatepass = new ExcelGatePassMain();

                if (duplicategatepass != null)
                {
                    return(File(gatepass.gate_pass(duplicategatepass.session, duplicategatepass.gate_pass_no, std.Userpic), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Gate Pas.xlsx"));
                }
                else
                {
                    std_halfday_logMain main = new std_halfday_logMain();

                    mst_sessionMain sess = new mst_sessionMain();

                    std.session = sess.findFinal_Session();

                    return(File(gatepass.gate_pass(std.session, main.AddHalfDayLog(std), std.Userpic), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Gate Pas.xlsx"));
                }
            }
        }
Example #2
0
        public int AddHalfDayLog(std_halfday_log std)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = @"SELECT 
                                            IFNULL(MAX(gate_pass_no), 0) + 1
                                        FROM
                                            std_halfday_log
                                        WHERE
                                            session = @session";

                    std.gate_pass_no = con.Query <int>(query, new { session = std.session }).SingleOrDefault();

                    std.date_time = DateTime.Now;

                    query = @"INSERT INTO `std_halfday_log`
                                (`gate_pass_no`,
                                `session`,
                                `sr_number`,
                                `date_time`,
                                `std_relation`,
                                `escorter_name`,
                                `escorter_address`,
                                `reason`)
                                VALUES
                                (@gate_pass_no,
                                @session,
                                @sr_number,
                                @date_time,
                                @std_relation,
                                @escorter_name,
                                @escorter_address,
                                @reason);";

                    con.Execute(query, std);

                    return(std.gate_pass_no);
                }
            }
            catch (Exception ex)
            {
                //do for error handling
            }
            return(0);
        }
Example #3
0
        public ActionResult std_half_day()
        {
            std_halfday_log log = new std_halfday_log();

            if (Convert.ToString(Session["CapturedImage"]) != string.Empty)
            {
                ViewBag.pic              = Session["CapturedImage"].ToString();
                ViewBag.disable          = "";
                log.Userpic              = Session["CapturedImage"].ToString();
                Session["CapturedImage"] = "";
            }
            else
            {
                ViewBag.pic = "../../images/person.png";
                Session["CapturedImage"] = "";
                ViewBag.disable          = "disabled";
                log.Userpic = "../../images/person.png";
            }
            return(View(log));
        }