public void AddFin(mst_fin mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = @"INSERT INTO mst_fin
                               (fin_id
		                       ,fin_start_date
                               ,fin_end_date
                               ,fin_close)
                                VALUES
                               (@fin_id
		                       ,@fin_start_date
                               ,@fin_end_date
                               ,@fin_close)";

                    mst.fin_close = "N";

                    con.Execute(query, new
                    {
                        mst.fin_id,
                        mst.fin_start_date,
                        mst.fin_end_date,
                        mst.fin_close
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void EditFin(mst_fin mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = "UPDATE mst_fin SET fin_close = @fin_close WHERE fin_id = @fin_id";

                    con.Execute(query, mst);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool checkFYnotExpired()
        {
            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                String Query = @"SELECT fin_id
                          ,fin_start_date
                          ,fin_end_date
                          ,fin_close
                           FROM mst_fin
                           where fin_close = 'N'";

                mst_fin mst = con.Query <mst_fin>(Query).SingleOrDefault();

                if (System.DateTime.Now.AddMinutes(dateTimeOffSet).Date >= mst.fin_start_date && System.DateTime.Now.AddMinutes(dateTimeOffSet).Date <= mst.fin_end_date.Date)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #4
0
        public async Task AddRegistration(std_registration std)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    mst_fin fin = new mst_fin();

                    string query1 = @"SELECT fin_id
                              ,fin_start_date
                              ,fin_end_date
                              ,fin_close
                          FROM mst_fin
                          where fin_close = 'N'";

                    fin = con.Query <mst_fin>(query1).SingleOrDefault();

                    if (std.reg_date > fin.fin_start_date && std.reg_date < fin.fin_end_date)
                    {
                        string sess = @"SELECT 
                                        session
                                    FROM
                                        mst_session
                                    WHERE
                                        session_active = 'Y'";

                        string session = con.ExecuteScalar <string>(sess);

                        string maxid = @"SELECT 
                                            IFNULL(MAX(reg_no), 0) + 1
                                        FROM
                                            sr_register
                                        WHERE
                                            adm_session = @adm_session";

                        int id = con.Query <int>(maxid, new { adm_session = session }).SingleOrDefault();

                        string max = @"SELECT 
                                        IFNULL(MAX(reg_no), 0) + 1
                                    FROM
                                        std_registration
                                    WHERE
                                        session = @adm_session";

                        int id1 = con.Query <int>(max, new { adm_session = session }).SingleOrDefault();



                        string query = @"INSERT INTO std_registration
           (session
           ,reg_no
           ,reg_date
           ,std_first_name
           ,std_last_name
           ,std_father_name
           ,std_mother_name
           ,std_address
           ,std_address1
           ,std_address2
           ,std_district
           ,std_state
           ,std_country
           ,std_pincode
           ,std_contact
           ,std_contact1
           ,std_contact2
           ,std_email
           ,std_class_id)
     VALUES
           (@session
           ,@reg_no
           ,@reg_date
           ,@std_first_name
           ,@std_last_name
           ,@std_father_name
           ,@std_mother_name
           ,@std_address
           ,@std_address1
           ,@std_address2
           ,@std_district
           ,@std_state
           ,@std_country
           ,@std_pincode
           ,@std_contact
           ,@std_contact1
           ,@std_contact2
           ,@std_email
           ,@std_class_id)";

                        std.session = session;

                        if (id1 < id)
                        {
                            std.reg_no = id;
                        }
                        else
                        {
                            std.reg_no = id1;
                        }
                        std.reg_date = System.DateTime.Now.AddMinutes(dateTimeOffSet);



                        await con.ExecuteAsync(query,
                                               new
                        {
                            std.session
                            ,
                            std.reg_no
                            ,
                            std.reg_date
                            ,
                            std.std_first_name
                            ,
                            std.std_last_name
                            ,
                            std.std_father_name
                            ,
                            std.std_mother_name
                            ,
                            std.std_address
                            ,
                            std.std_address1
                            ,
                            std.std_address2
                            ,
                            std.std_district
                            ,
                            std.std_state
                            ,
                            std.std_country
                            ,
                            std.std_pincode
                            ,
                            std.std_contact
                            ,
                            std.std_contact1
                            ,
                            std.std_contact2
                            ,
                            std.std_email
                            ,
                            std.std_class_id
                        });

                        out_standing out_std = new out_standing();

                        out_std.acc_id        = 1;
                        out_std.outstd_amount = std.fees_amount;
                        out_std.reg_num       = std.reg_no;

                        out_standingMain out_stdMain = new out_standingMain();



                        out_stdMain.AddOutStanding(out_std);
#if !DEBUG
                        SMSMessage sms = new SMSMessage();



                        foreach (var item in sms.smsbody("student_registration"))
                        {
                            string qry = @"SELECT 
                                        class_name
                                    FROM
                                        mst_class
                                    WHERE
                                        class_id = @class_id
                                            AND session = (SELECT
                                                session
                                            FROM
                                                mst_session
                                            WHERE
                                                session_active = 'Y')";

                            string className = con.Query <string>(qry, new { class_id = std.std_class_id }).SingleOrDefault();

                            string body = item.Replace("#student_name#", std.std_first_name + " " + std.std_last_name);

                            body = body.Replace("#class#", className);

                            await sms.SendSMS(body, std.std_contact, true);
                        }

                        //string text =  std.std_first_name+" "+ std.std_last_name+" is successfully registered in class "+ className + @". This registration is valid for 3 days subject to availability of seats. Thank You. Hariti Public School.";

                        //sms.SendSMS(text, std.std_contact);

                        // text = std.std_first_name + " " + std.std_last_name + " का पंजीकरण कक्षा " + className + " में सफलतापूर्वक हो गया है। यह पंजीकरण 3 दिन तक मान्य रहेगा। कक्षा में सीटों की उपलब्धता सीमित हैं। धन्यवाद। Hariti Public School";

                        //sms.SendSMS(text, std.std_contact);
#endif
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }