public void updateReceipt(fees_receipt fees)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = @"UPDATE fees_receipt
                               SET sr_number = @sr_number
                                  ,class_id = @class_id
                                  ,section_id = @section_id
                             WHERE 
		                            reg_no = @reg_no
		                            and
		                            reg_date = @reg_date"        ;

                    con.Execute(query, new
                    {
                        sr_number  = fees.sr_number,
                        class_id   = fees.class_id,
                        section_id = fees.section_id,
                        reg_no     = fees.reg_no,
                        reg_date   = fees.reg_date
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public async Task AddStudent(sr_register std)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    mst_sessionMain sess = new mst_sessionMain();

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

                    //                var id = con.Query<mst_section>(maxid).ToString().Trim();

                    int id = con.ExecuteScalar <int>(maxid);



                    string query = @"INSERT INTO sr_register
                                   (sr_number
                                   ,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_father_occupation
                                   ,std_mother_occupation
                                   ,std_blood_gp
                                   ,std_house_income
                                   ,std_nationality
                                   ,std_category
                                   ,std_cast
                                   ,std_dob
                                   ,std_sex
                                   ,std_last_school
                                   ,std_admission_date
                                   ,std_house
                                   ,std_remark
                                   ,std_active
                                   ,std_pickup_id
                                   ,std_admission_class
                                   ,adm_session
                                   ,reg_no
                                   ,reg_date
                                   ,std_aadhar)
                             VALUES
                                   (@sr_number
                                   ,@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_father_occupation
                                   ,@std_mother_occupation
                                   ,@std_blood_gp
                                   ,@std_house_income
                                   ,@std_nationality
                                   ,@std_category
                                   ,@std_cast
                                   ,@std_dob
                                   ,@std_sex
                                   ,@std_last_school
                                   ,@std_admission_date
                                   ,@std_house
                                   ,@std_remark
                                   ,@std_active
                                   ,@std_pickup_id
                                   ,@std_admission_class
                                   ,@adm_session
                                   ,@reg_no
                                   ,@reg_date
                                   ,@std_aadhar)";



                    std.std_active         = "Y";
                    std.sr_number          = id;
                    std.std_admission_date = DateTime.Parse(std.std_admission_date_str);
                    std.std_dob            = DateTime.Parse(std.std_dob_str);
                    await con.ExecuteAsync(query,
                                           new
                    {
                        std.sr_number
                        ,
                        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_father_occupation
                        ,
                        std.std_mother_occupation
                        ,
                        std.std_blood_gp
                        ,
                        std.std_house_income
                        ,
                        std.std_nationality
                        ,
                        std.std_category
                        ,
                        std.std_cast
                        ,
                        std.std_dob
                        ,
                        std.std_sex
                        ,
                        std.std_last_school
                        ,
                        std.std_admission_date
                        ,
                        std.std_admission_class
                        ,
                        std.std_house
                        ,
                        std.std_remark
                        ,
                        std.std_pickup_id
                        ,
                        std.std_active
                        ,
                        std.adm_session
                        ,
                        std.reg_no
                        ,
                        std.reg_date
                        ,
                        std.std_aadhar
                    });

                    query = @"INSERT INTO `mst_std_class`
                            (`session`,
                            `sr_num`,
                            `class_id`)
                            VALUES
                            (@session,
                            @sr_num,
                            @class_id)";



                    await con.ExecuteAsync(query, new { session = sess.findActive_Session(), sr_num = std.sr_number, class_id = std.class_id });

                    query = @"INSERT INTO `mst_std_section`
                            (`session`,
                            `sr_num`,
                            `section_id`)
                            VALUES
                            (@session,
                            @sr_num,
                            @section_id)";



                    await con.ExecuteAsync(query, new { session = sess.findActive_Session(), sr_num = std.sr_number, section_id = std.std_section_id });

                    std_registrationMain main = new std_registrationMain();

                    main.DeleteRegistrationOnly(std.adm_session, std.reg_no, std.reg_date);

                    fees_receiptMain mstfees = new fees_receiptMain();
                    fees_receipt     fees    = new fees_receipt();

                    fees.sr_number  = std.sr_number;
                    fees.class_id   = std.class_id;
                    fees.section_id = std.std_section_id;

                    fees.reg_no = std.reg_no;

                    fees.reg_date = std.reg_date;

                    mstfees.updateReceipt(fees);

                    out_standing out_std = new out_standing();

                    out_std.acc_id        = 2;
                    out_std.outstd_amount = std.fees_amount;


                    out_standingMain out_stdMain = new out_standingMain();

                    out_std.sr_number = std.sr_number;
                    out_std.class_id  = std.class_id;

                    out_stdMain.AddOutStanding(out_std);

                    query = @"SELECT 
                                acc_id, fees_amount outstd_amount
                            FROM
                                mst_fees
                            WHERE
                                session = @session AND bl_onetime = 1
                                    AND acc_id not in (2,1)
                                    AND class_id = @class_id";

                    out_standing out_std_onetime = new out_standing();

                    out_std_onetime = con.Query <out_standing>(query, new { session = sess.findActive_Session(), class_id = std.class_id }).SingleOrDefault();

                    if (out_std_onetime != null)
                    {
                        out_std_onetime.sr_number = std.sr_number;

                        out_std_onetime.class_id = std.class_id;

                        out_stdMain.AddOutStanding(out_std_onetime);
                    }

                    out_std.reg_num = std.reg_no;

                    out_std.dt_date = std.reg_date;

                    out_std.class_id = std.class_id;

                    out_stdMain.updateOutstanding(out_std);

                    var p = new DynamicParameters();
#if !DEBUG
                    SMSMessage sms = new SMSMessage();

                    foreach (var item in sms.smsbody("admission"))
                    {
                        string body = item.Replace("#student_name#", std.std_first_name + " " + std.std_last_name);

                        body = body.Replace("#class#", std.std_admission_class);

                        body = body.Replace("#sr_number#", std.sr_number.ToString());

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

                    //string text = @"Admission of " + std.std_first_name + " " + std.std_last_name + " is confirmed in class " + std.std_admission_class + " via admission number " + std.sr_number + ". Congratulation for being a part of hariti family. Thank You. Hariti Public School.";

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

                    // text =  std.std_first_name + " " + std.std_last_name + " का प्रवेश कक्षा "+std.std_admission_class+" में होना सुनिश्चित हुआ है। जिसका प्रवेश क्रमांक " + std.sr_number + " है। हरिति परिवार से जुड़ने के लिये आपका धन्यवाद। Hariti Public School.";

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


                    p.Add("@sr_num", std.sr_number);


                    con.Execute("MonthlyFeesFullYear", p, commandType: System.Data.CommandType.StoredProcedure);

                    con.Execute("MonthlyTransportFullYear", p, commandType: System.Data.CommandType.StoredProcedure);

                    DashboardHub hub = new DashboardHub();

                    hub.DashboardSchoolStrength();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }