示例#1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            var Result          = false;
            var Message         = "Oh, import failed please review error log.";
            var NamePos         = Convert.ToInt32(cbName.SelectedValue);
            var EmailPos        = Convert.ToInt32(cbEmail.SelectedValue);
            var SexPos          = Convert.ToInt32(cbSex.SelectedValue);
            var MobilePos       = Convert.ToInt32(cbMobile.SelectedValue);
            var RolePos         = Convert.ToInt32(cbRole.SelectedValue);
            var KindergartenPos = Convert.ToInt32(cbKindergarten.SelectedValue);

            try
            {
                Result = GetUsersInstance().Insert(NamePos, EmailPos, SexPos, MobilePos, RolePos, KindergartenPos, Users, IsTry2Import);

                if (Result)
                {
                    Message = "Import Users Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Users Fail.", SysLogType.ERROR, "Import Users FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Users FRM"));
            }
            finally
            {
                IsTry2Import = false;
                MessageBox.Show(Message);
            }
        }
示例#2
0
        public void InsertSysLog(SyslogInfo syslogInfo)
        {
            try
            {
                SysLogInfo model = new SysLogInfo();
                model.AppName         = syslogInfo.AppName;
                model.MethodName      = syslogInfo.MethodName;
                model.Message         = syslogInfo.Message;
                model.LastUpdatedDate = syslogInfo.LastUpdatedDate;

                SysLog bll = new SysLog();
                bll.Insert(model);
            }
            catch (Exception ex)
            {
                SysLogInfo model = new SysLogInfo();
                model.AppName         = "应用程序日志服务系统";
                model.MethodName      = "SysLogService.InsertSysLog";
                model.Message         = "异常:" + ex.Message + ",请求参数:appName='" + syslogInfo.AppName + "',methodName='" + syslogInfo.MethodName + "',message='" + syslogInfo.Message + "'";
                model.LastUpdatedDate = syslogInfo.LastUpdatedDate;

                SysLog bll = new SysLog();
                bll.Insert(model);
            }
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            var Result          = false;
            var Message         = "Oh, import failed please review error log.";
            var ClassNamePos    = Convert.ToInt32(cbClassName.SelectedValue);
            var TypePos         = Convert.ToInt32(cbType.SelectedValue);
            var StartDatePos    = Convert.ToInt32(cbStartDate.SelectedValue);
            var EndDatePos      = Convert.ToInt32(cbEndDate.SelectedValue);
            var HoursPos        = Convert.ToInt32(cbHours.SelectedValue);
            var PricePos        = Convert.ToInt32(cbPrice.SelectedValue);
            var AmountPos       = Convert.ToInt32(cbAmount.SelectedValue);
            var CategoryNamePos = Convert.ToInt32(cbCategory.SelectedValue);
            var StatusPos       = Convert.ToInt32(cbStatus.SelectedValue);
            var ChargeTypePos   = Convert.ToInt32(cbChargeType.SelectedValue);

            try
            {
                if (GetInterestClassInstance().InterestInsert(Classes, ClassNamePos, TypePos, StartDatePos, EndDatePos, HoursPos, PricePos, AmountPos, CategoryNamePos, StatusPos, ChargeTypePos, IsTry2Import))
                {
                    Message = "Import Interest Class Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Interest Class Fail.", SysLogType.ERROR, "Import Interest Class FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Interest Class FRM"));
            }
            finally {
                IsTry2Import = false;
                MessageBox.Show(Message);
            }
        }
示例#4
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            var AcadYear           = cbYear.SelectedValue.ToString();
            var PlanTitlePos       = int.Parse(cbPlanTitle.SelectedValue.ToString());
            var PlanDescriptionPos = int.Parse(cbPlanDescription.SelectedValue.ToString());
            var Result             = false;
            var Message            = "Oh, import failed please review error log.";

            try
            {
                Result = GetClassInstance().InsertPlan(AcadYear, PlanTitlePos, PlanDescriptionPos, Plans, IsTry2Import);

                if (Result)
                {
                    Message = "Import Class Plan Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Plan Fail.", SysLogType.ERROR, "Import Class FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Class FRM"));
            }
            finally
            {
                IsTry2Import = false;
                MessageBox.Show(Message);
            }
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            btnImport.Enabled = false;
            var Message = "Oh, import class failed please review error log.";
            var Result  = false;

            var AcadYear       = cbYear.SelectedValue.ToString();
            var StudentNamePos = Convert.ToInt32(cbStudentName.SelectedValue);
            var CardTypePos    = Convert.ToInt32(cbCardType.SelectedValue);
            var IdCardPos      = Convert.ToInt32(cbIDCard.SelectedValue);
            var LastNamePos    = Convert.ToInt32(cbLastName.SelectedValue);
            var FirstNamePos   = Convert.ToInt32(cbFirstName.SelectedValue);
            var NationalityPos = Convert.ToInt32(cbNationality.SelectedValue);
            var SexPos         = Convert.ToInt32(cbSex.SelectedValue);
            var BirthDayPos    = Convert.ToInt32(cbBirthDay.SelectedValue);
            var StudentNoPos   = Convert.ToInt32(cbStudentNo.SelectedValue);
            var StatusPos      = Convert.ToInt32(cbStatus.SelectedValue);
            var PlanTimePos    = Convert.ToInt32(cbPlanTime.SelectedValue);
            var NationPos      = Convert.ToInt32(cbNation.SelectedValue);

            var GuardianNamePos         = Convert.ToInt32(cbGuardianName.SelectedValue);
            var GuardianMobileNoPos     = Convert.ToInt32(cbMobileNo.SelectedValue);
            var GuardianRelationshipPos = Convert.ToInt32(cbRelationship.SelectedValue);
            var GuardianEducationPos    = Convert.ToInt32(cbEducation.SelectedValue);
            var GuardianJobPos          = Convert.ToInt32(cbJob.SelectedValue);
            var GuardianCompanyPos      = Convert.ToInt32(cbCompany.SelectedValue);
            var ParentNamePos           = Convert.ToInt32(cbcParnetName.SelectedValue);
            var MobileNoPos             = Convert.ToInt32(cbcMobileNo.SelectedValue);
            var RelationshipPos         = Convert.ToInt32(cbcRelationship.SelectedValue);
            var EducationPos            = Convert.ToInt32(cbcEducation.SelectedValue);
            var JobPos     = Convert.ToInt32(cbcJob.SelectedValue);
            var CompanyPos = Convert.ToInt32(cbcCompany.SelectedValue);

            var ClassNamePos = Convert.ToInt32(cbClassName.SelectedValue);

            var ParentName3Pos   = Convert.ToInt32(cb3ParentName.SelectedValue);
            var MobileNo3Pos     = Convert.ToInt32(cb3MobileNo.SelectedValue);
            var Relationship3Pos = Convert.ToInt32(cb3Relationship.SelectedValue);
            var Education3Pos    = Convert.ToInt32(cb3Education.SelectedValue);
            var Job3Pos          = Convert.ToInt32(cb3Job.SelectedValue);
            var Company3Pos      = Convert.ToInt32(cb3Company.SelectedValue);

            try
            {
                Result  = GetStudentInstance().Insert(Students, AcadYear, StudentNamePos, CardTypePos, IdCardPos, LastNamePos, FirstNamePos, NationalityPos, SexPos, BirthDayPos, StudentNoPos, StatusPos, PlanTimePos, NationPos, GuardianNamePos, GuardianMobileNoPos, GuardianRelationshipPos, GuardianEducationPos, GuardianJobPos, GuardianCompanyPos, ParentNamePos, MobileNoPos, RelationshipPos, EducationPos, JobPos, CompanyPos, ClassNamePos, ParentName3Pos, MobileNo3Pos, Relationship3Pos, Education3Pos, Job3Pos, Company3Pos, IsTry2Import);
                Message = "Import Student Successfully!!!";
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message, SysLogType.ERROR, BznsStudent.ModuleName + " FRM"));
            }
            finally {
                IsTry2Import = false;
                MessageBox.Show(Message);
                btnImport.Enabled = true;
            }
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            var Result                = false;
            var Message               = "Oh, import failed please review error log.";
            var NamePos               = Convert.ToInt32(cbName.SelectedValue);
            var LastNamePos           = Convert.ToInt32(cbLastName.SelectedValue);
            var FirstNamePos          = Convert.ToInt32(cbFirstName.SelectedValue);
            var SexPos                = Convert.ToInt32(cbSex.SelectedValue);
            var NationalityPos        = Convert.ToInt32(cbNationality.SelectedValue);
            var NationPos             = Convert.ToInt32(cbNation.SelectedValue);
            var IDCardTypePos         = Convert.ToInt32(cbIDCardType.SelectedValue);
            var IDCardNoPos           = Convert.ToInt32(cbIDCardNo.SelectedValue);
            var BirthdayPos           = Convert.ToInt32(cbBirthday.SelectedValue);
            var MobileNoPos           = Convert.ToInt32(cbMobileNo.SelectedValue);
            var EmailAddressPos       = Convert.ToInt32(cbEmailAddress.SelectedValue);
            var IsPreEduPos           = Convert.ToInt32(cbIsPreEdu.SelectedValue);
            var ForeignNationalityPos = Convert.ToInt32(cbForeignNationality.SelectedValue);
            var TeacherLevelPos       = Convert.ToInt32(cbTeacherLevel.SelectedValue);
            var EduQualificationPos   = Convert.ToInt32(cbEduQualification.SelectedValue);
            var ProfessionPos         = Convert.ToInt32(cbProfession.SelectedValue);
            var UniversityPos         = Convert.ToInt32(cbUniversity.SelectedValue);
            var ClassIdPos            = Convert.ToInt32(cbClassId.SelectedValue);
            var KindergartenIdPos     = Convert.ToInt32(cbKindergartenId.SelectedValue);
            var AccountPos            = Convert.ToInt32(cbAccount.SelectedValue);

            try
            {
                Result = GetTeacherInstance().InsertTeacher(IsTry2Import, Teachers, NamePos, LastNamePos, FirstNamePos, SexPos, NationalityPos, NationPos, IDCardTypePos, IDCardNoPos, BirthdayPos, MobileNoPos, EmailAddressPos, IsPreEduPos, ForeignNationalityPos, TeacherLevelPos, EduQualificationPos, ProfessionPos, UniversityPos, ClassIdPos, KindergartenIdPos, AccountPos);

                if (Result)
                {
                    Message = "Import Finance Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Finance Fail.", SysLogType.ERROR, "Import Finance FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Finance FRM"));
            }
            finally
            {
                IsTry2Import = false;
                MessageBox.Show(Message);
            }
        }
示例#7
0
        private void exportClassToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var myClass  = new BznsClass();
            var FilePath = ConfigurationManager.AppSettings["ExportClassFilePath"];
            var Message  = "We're sorry, export class list error.";

            try
            {
                var dt = myClass.GetClassList();
                ExcelHelper.ExcelHelper.DataTableToExcel(dt, string.Empty, FilePath);
                Message = string.Concat("Successfully,Please goto your location of ", FilePath, " to view.");
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Export Class FRM"));
            }
            finally {
                myClass = null;
                MessageBox.Show(Message);
            }
        }
示例#8
0
        private void btnImportClass_Click(object sender, EventArgs e)
        {
            var AcadYear           = cbcYear.SelectedValue.ToString();
            var PlanID             = cbcPlanName.SelectedValue.ToString();
            var SchoolColPos       = int.Parse(cbcSchoolCal.SelectedValue.ToString());
            var ClassTypePos       = int.Parse(cbcClassType.SelectedValue.ToString());
            var ClassNamePos       = int.Parse(cbcClassName.SelectedValue.ToString());
            var CapacityPos        = int.Parse(cbcCapacity.SelectedValue.ToString());
            var StartTimePos       = int.Parse(cbcTeachStartTime.SelectedValue.ToString());
            var EndTimePos         = int.Parse(cbcTeachEndTime.SelectedValue.ToString());
            var ClassAliasPos      = int.Parse(cbcClassAlias.SelectedValue.ToString());
            var GradeTypePos       = int.Parse(cbcGradeType.SelectedValue.ToString());
            var AllowOverbookedPos = int.Parse(cbcOverbooked.SelectedValue.ToString());
            var Result             = false;
            var Message            = "Oh, import class failed please review error log.";

            try
            {
                Result = GetClassInstance().InsertClass(AcadYear, PlanID, SchoolColPos, ClassTypePos, ClassNamePos, CapacityPos, StartTimePos, EndTimePos, ClassAliasPos, GradeTypePos, AllowOverbookedPos, Classes, IsTry2Import);

                if (Result)
                {
                    Message = "Import Class Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Class Fail.", SysLogType.ERROR, "Import Class FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Class FRM"));
            }
            finally
            {
                IsTry2Import = false;
                MessageBox.Show(Message);
            }
        }
示例#9
0
        public bool Insert(int NamePos, int EmailPos, int SexPos, int MobilePos, int RolePos, int KindergartenPos, DataTable Users, bool IsTry2Import)
        {
            var result     = false;
            var Sql        = string.Empty;
            var CreateDate = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Users.Rows)
                    {
                        var UserId = InitObject.GetUUID();

                        var Name             = NamePos == -1 ? string.Empty : dr[NamePos].ToString().Trim();
                        var Email            = EmailPos == -1 ? string.Empty : dr[EmailPos].ToString().Trim();
                        var Sex              = SexPos == -1 ? 0 : dr[SexPos].ToString().Trim() == "男"? 1:0;
                        var Mobile           = MobilePos == -1 ? string.Empty : dr[MobilePos].ToString().Trim();
                        var Role             = RolePos == -1 ? string.Empty : dr[RolePos].ToString().Trim();
                        var Kindergarten     = KindergartenPos == -1 ? string.Empty : dr[KindergartenPos].ToString().Trim();
                        var RoleInfo         = new RoleInfo();
                        var KindergartenInfo = new KindergartenInfo();
                        var ret              = 0;

                        if (!string.IsNullOrEmpty(Role.Trim()))
                        {
                            RoleInfo = InitObject.GetRoleInfoByTitle(Role.Trim());
                        }

                        if (!string.IsNullOrEmpty(Kindergarten.Trim()))
                        {
                            KindergartenInfo = InitObject.GetKindergartenInfoByName(Kindergarten.Trim());
                        }


                        try
                        {
                            if (!string.IsNullOrEmpty(Email.Trim()) && !string.IsNullOrEmpty(Name.Trim()) && !string.IsNullOrEmpty(RoleInfo.RoleId) && !string.IsNullOrEmpty(KindergartenInfo.Id))
                            {
                                // Insert into upms user

                                Sql = string.Format(InitObject.GetScriptServiceInstance().UserInsert, UserId, Name, BznsBase.UserPassword, BznsBase.UserPasswordSalt, Name, Mobile, Email, KindergartenInfo.Id, BznsBase.BrandID, Sex);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                // Insert into upms role

                                var UserRoleId = InitObject.GetUUID();

                                if (ret > 0)
                                {
                                    ret = 0;
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().RoleInsert, UserRoleId, UserId, RoleInfo.RoleId);
                                    ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                }

                                // Insert into user kindergarten

                                if (ret > 0)
                                {
                                    ret = 0;
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().UserKindergartenInsert, UserId, KindergartenInfo.Id);
                                    ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Users LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally
                        {
                        }
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName)));
                    trans.Rollback();
                }
                finally
                {
                    trans = null;
                }
            }


            return(result);
        }
示例#10
0
        public bool InsertPlan(string AcadYear, int PlanTitlePos, int PlanDescriptionPos, DataTable Plans, bool IsTry2Import)
        {
            var Result         = false;
            var KindergartenId = BznsBase.KindergartenId;
            var BrandId        = BznsBase.BrandID;
            var UserID         = BznsBase.UserID;
            var Sql            = string.Empty;
            var PlanID         = string.Empty;
            var CreateDate     = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Plans.Rows)
                    {
                        PlanID = InitObject.GetUUID();
                        var PlanTitle       = PlanTitlePos == -1 ? string.Empty : dr[PlanTitlePos].ToString();
                        var PlanDescription = PlanDescriptionPos == -1 ? string.Empty : dr[PlanDescriptionPos].ToString();

                        try
                        {
                            Sql = string.Format(InitObject.GetScriptServiceInstance().ClassPlanInsert, PlanID, AcadYear, PlanTitle, PlanDescription, UserID, KindergartenId, BrandId, CreateDate);
                            DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                            Sql = string.Format(InitObject.GetScriptServiceInstance().ClassPlanLogInsert, InitObject.GetUUID(), PlanID, "开班计划申请", UserID, CreateDate, "", "", CreateDate);
                            DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                            Sql = string.Format(InitObject.GetScriptServiceInstance().ClassPlanLogInsert, InitObject.GetUUID(), PlanID, "开班计划审核", BznsBase.BrandUserID, CreateDate, "同意", "已审核通过", CreateDate);
                            DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Plan LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally {
                        }
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    Result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName, " - ", "Import Class Plan Bzns")));
                    trans.Rollback();
                }
                finally
                {
                    trans = null;
                }
            }

            return(Result);
        }
示例#11
0
        public bool InsertClass(string AcadYear, string PlanID, int SchoolCalPos, int ClassTypePos, int ClassNamePos, int CapacityPos, int StartTimePos, int EndTimePos, int ClassAliasPos, int GradeTypePos, int AllowOverbookedPos, DataTable Classes, bool IsTry2Import)
        {
            var Result         = false;
            var KindergartenId = BznsBase.KindergartenId;
            var BrandId        = BznsBase.BrandID;
            var UserID         = BznsBase.UserID;
            var Sql            = string.Empty;
            var ClassID        = string.Empty;
            var CreateDate     = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Classes.Rows)
                    {
                        ClassID = InitObject.GetUUID();
                        var SchoolCal       = SchoolCalPos == -1 ? string.Empty : dr[SchoolCalPos].ToString();
                        var ClassType       = ClassTypePos == -1 ? string.Empty : InitObject.GetClassTypeByName(dr[ClassTypePos].ToString());
                        var ClassName       = ClassNamePos == -1 ? string.Empty : dr[ClassNamePos].ToString();
                        var Capacity        = CapacityPos == -1 ? 0:int.Parse(dr[CapacityPos].ToString());
                        var StartTime       = StartTimePos == -1 ? string.Empty : dr[StartTimePos].ToString();
                        var EndTime         = EndTimePos == -1 ? string.Empty : dr[EndTimePos].ToString();
                        var ClassAlias      = ClassAliasPos == -1 ? string.Empty : dr[ClassAliasPos].ToString();
                        var GradeType       = GradeTypePos == -1 ? string.Empty : InitObject.GetGradeTypeByName(dr[GradeTypePos].ToString());
                        var AllowOverbooked = AllowOverbookedPos == -1 ? string.Empty : dr[AllowOverbookedPos].ToString();
                        var CalInfo         = new CalInfo();

                        if (!string.IsNullOrEmpty(SchoolCal))
                        {
                            CalInfo = GetCalInfoByTitle(SchoolCal);
                        }

                        try
                        {
                            Sql = string.Format(InitObject.GetScriptServiceInstance().ClassTempInsert, AcadYear, PlanID, ClassID, GradeType, ClassType, CalInfo.CalID, ClassName, ClassAlias, Capacity, AllowOverbooked, StartTime, EndTime, UserID, CreateDate, KindergartenId);
                            DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                            Sql = string.Format(InitObject.GetScriptServiceInstance().ClassInsert, AcadYear, PlanID, ClassID, GradeType, ClassType, CalInfo.CalID, ClassName, ClassAlias, Capacity, AllowOverbooked, StartTime, EndTime, UserID, CreateDate, KindergartenId);
                            DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Class LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally {
                        }
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    Result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName, " - ", "Import Class Bzns")));
                    trans.Rollback();
                }
                finally
                {
                    trans = null;
                }
            }

            return(Result);
        }
示例#12
0
        private void isbtnImport_Click(object sender, EventArgs e)
        {
            var Result        = false;
            var Message       = "Oh, import failed please review error log.";
            var StudentNoPos  = Convert.ToInt32(iscbStudentNo.SelectedValue);
            var YearPos       = Convert.ToInt32(iscbYear.SelectedValue);
            var CourseNamePos = Convert.ToInt32(iscbCourseName.SelectedValue);
            var ClassHoursPos = Convert.ToInt32(iscbClassHours.SelectedValue);
            var MoneyPos      = Convert.ToInt32(iscbMoney.SelectedValue);
            var PaidPos       = Convert.ToInt32(iscbPaid.SelectedValue);
            var StartDatePos  = Convert.ToInt32(iscbStartDate.SelectedValue);
            var EndDatePos    = Convert.ToInt32(iscbEndDate.SelectedValue);

            try
            {
                if (StudentNoPos == -1)
                {
                    Message = "Please select your student no.";
                    return;
                }

                if (YearPos == -1)
                {
                    Message = "Please select your acad year.";
                    return;
                }

                if (CourseNamePos == -1)
                {
                    Message = "Please select your course name.";
                    return;
                }

                if (ClassHoursPos == -1)
                {
                    Message = "Please select your class hours.";
                    return;
                }

                if (MoneyPos == -1)
                {
                    Message = "Please select your money.";
                    return;
                }

                if (GetInterestClassInstance().StudentInsert(Students, StudentNoPos, YearPos, CourseNamePos, ClassHoursPos, MoneyPos, PaidPos, StartDatePos, EndDatePos, IsTry2))
                {
                    Message = "Import Interest Class Student Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Interest Class Student Fail.", SysLogType.ERROR, "Import Interest Class FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Interest Class FRM"));
            }
            finally
            {
                IsTry2 = false;
                MessageBox.Show(Message);
            }
        }
示例#13
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            btnImport.Enabled = false;

            var Result           = false;
            var Message          = "Oh, import failed please review error log.";
            var StudentNoPos     = Convert.ToInt32(cbStudentNo.SelectedValue);
            var YearTitlePos     = Convert.ToInt32(cbYear.SelectedValue);
            var MonthPos         = Convert.ToInt32(cbMonth.SelectedValue);
            var BillStartDatePos = Convert.ToInt32(cbBillStartDate.SelectedValue);

            var PaymentMethodPos      = Convert.ToInt32(cbtfPaymentMethod.SelectedValue);
            var TuitionFeeMoneyPos    = Convert.ToInt32(cbtfTuitionFeeMoney.SelectedValue);
            var DiscountMoneyPos      = Convert.ToInt32(cbtfDiscountMoney.SelectedValue);
            var DiscountNamePos       = Convert.ToInt32(cbDiscountName.SelectedValue);
            var StartDatePos          = Convert.ToInt32(cbtfStartDate.SelectedValue);
            var PerTuitionFeeMoneyPos = Convert.ToInt32(cbptfmPerTuitionFeeMoney.SelectedValue);

            var mfMethodPos    = Convert.ToInt32(cbmfMethod.SelectedValue);
            var mfMoneyPos     = Convert.ToInt32(cbmfMoney.SelectedValue);
            var mfStartDatePos = Convert.ToInt32(cbmfStartDate.SelectedValue);

            var scMethodPos    = Convert.ToInt32(cbscMethod.SelectedValue);
            var scMoneyPos     = Convert.ToInt32(cbscMoney.SelectedValue);
            var scStartDatePos = Convert.ToInt32(cbscStartDate.SelectedValue);
            var scMonthPos     = Convert.ToInt32(cbscMonth.SelectedValue);

            var ofMoney1Pos = Convert.ToInt32(cbofMoney1.SelectedValue);
            var ofMoney2Pos = Convert.ToInt32(cbofMoney2.SelectedValue);
            var ofMoney3Pos = Convert.ToInt32(cbofMoney3.SelectedValue);
            var ofMoney4Pos = Convert.ToInt32(cbofMoney4.SelectedValue);
            var ofMoney5Pos = Convert.ToInt32(cbofMoney5.SelectedValue);
            var ofMoney6Pos = Convert.ToInt32(cbofMoney6.SelectedValue);
            var ofMoney7Pos = Convert.ToInt32(cbofMoney7.SelectedValue);

            var ofs = new List <OnceInfo>();

            try
            {
                if (BillStartDatePos == -1)
                {
                    Message = "Please select your bill start date.";
                    return;
                }

                if (StudentNoPos == -1)
                {
                    Message = "Please select your student no.";
                    return;
                }

                if (YearTitlePos == -1)
                {
                    Message = "Please select your school year.";
                    return;
                }

                if (MonthPos == -1)
                {
                    Message = "Please select your school year.";
                    return;
                }

                if (ofMoney1Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney1Pos, Value = cbofMoney1.Text.Trim()
                    });
                }

                if (ofMoney2Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney2Pos, Value = cbofMoney2.Text.Trim()
                    });
                }

                if (ofMoney3Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney3Pos, Value = cbofMoney3.Text.Trim()
                    });
                }

                if (ofMoney4Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney4Pos, Value = cbofMoney4.Text.Trim()
                    });
                }

                if (ofMoney5Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney5Pos, Value = cbofMoney5.Text.Trim()
                    });
                }

                if (ofMoney6Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney6Pos, Value = cbofMoney6.Text.Trim()
                    });
                }

                if (ofMoney7Pos != -1)
                {
                    ofs.Add(new OnceInfo()
                    {
                        Key = ofMoney7Pos, Value = cbofMoney7.Text.Trim()
                    });
                }


                //Result = GetFinanceInstance().BillInsert(Students, StudentNoPos, YearTitlePos, MonthPos, BillStartDatePos, PaymentMethodPos, TuitionFeeMoneyPos, DiscountMoneyPos, DiscountNamePos, StartDatePos, PerTuitionFeeMoneyPos, mfMethodPos, mfMoneyPos, mfStartDatePos, scMethodPos, scMoneyPos, scMonthPos, scStartDatePos, ofs, IsTry2Import);

                Result = GetFinanceInstance().ChargeInsert(Students, StudentNoPos, false);

                if (Result && !IsTry2Import)
                {
                    Result = GetFinanceInstance().ChargeInsert(Students, StudentNoPos, false);
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Payment Fail.", SysLogType.ERROR, "Import Finance FRM"));
                }

                if (Result)
                {
                    Message = "Import Finance Successfully!";
                }
                else
                {
                    SysLog.Insert(new SysLogInfo("Import Finance Fail.", SysLogType.ERROR, "Import Finance FRM"));
                }
            }
            catch (Exception ex)
            {
                SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, "Import Finance FRM"));
            }
            finally
            {
                IsTry2Import      = false;
                ofs               = null;
                btnImport.Enabled = true;
                MessageBox.Show(Message);
            }
        }
示例#14
0
        public bool Insert(DataTable Students, string AcadYear, int StudentNamePos, int CardTypePos, int IdCardPos, int LastNamePos, int FirstNamePos, int NationalityPos, int SexPos, int BirthDayPos, int StudentNoPos, int StatusPos, int PlanTimePos, int NationPos, int GuardianNamePos, int GuardianMobileNoPos, int GuardianRelationshipPos, int GuardianEducationPos, int GuardianJobPos, int GuardianCompanyPos, int ParentNamePos, int MobileNoPos, int RelationshipPos, int EducationPos, int JobPos, int CompanyPos, int ClassNamePos, int ParentName3Pos, int MobileNo3Pos, int Relationship3Pos, int Education3Pos, int Job3Pos, int Company3Pos, bool IsTry2Import)
        {
            var Result         = false;
            var KindergartenId = BznsBase.KindergartenId;
            var UserID         = BznsBase.UserID;
            var Sql            = string.Empty;
            var CreateDate     = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Students.Rows)
                    {
                        var StudentID   = InitObject.GetUUID();
                        var StudentName = StudentNamePos == -1 ? string.Empty : dr[StudentNamePos].ToString();
                        var CardType    = CardTypePos == -1 ? string.Empty : InitObject.GetIdType(dr[CardTypePos].ToString());
                        var IdCard      = IdCardPos == -1 ? string.Empty : dr[IdCardPos].ToString();
                        var LastName    = LastNamePos == -1 ? string.Empty : dr[LastNamePos].ToString();
                        var FirstName   = FirstNamePos == -1 ? string.Empty : dr[FirstNamePos].ToString();
                        var Nationality = NationalityPos == -1 ? string.Empty : dr[NationalityPos].ToString();
                        var Sex         = SexPos == -1 ? string.Empty : InitObject.GetSexByName(dr[SexPos].ToString());
                        var BirthDay    = BirthDayPos == -1 ? string.Empty : dr[BirthDayPos].ToString().Replace("/", "-");
                        var StudentNo   = StudentNoPos == -1 ? string.Empty : dr[StudentNoPos].ToString();
                        var Status      = StatusPos == -1 ? string.Empty : InitObject.GetStatusByName(dr[StatusPos].ToString());
                        var PlanTime    = PlanTimePos == -1 ? string.Empty : dr[PlanTimePos].ToString().Replace("/", "-");
                        var Nation      = NationPos == -1 ? string.Empty : InitObject.GetNationCodeByName(dr[NationPos].ToString());
                        var ClassName   = ClassNamePos == -1 ? string.Empty : dr[ClassNamePos].ToString();

                        if (string.IsNullOrWhiteSpace(ClassName))
                        {
                            Status = "STUSTATUS01";
                        }
                        else
                        {
                            Status = "STUSTATUS09";
                        }

                        // insert student info

                        try
                        {
                            if (!string.IsNullOrEmpty(StudentName.Trim()))
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().StudentInsert, AcadYear, KindergartenId, StudentID, StudentName, CardType, IdCard, LastName, FirstName, PlanTime, Nationality, Nation, Sex, BirthDay, CreateDate, Status, StudentNo, UserID);
                                var ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                // create one account for student

                                if (ret > 0)
                                {
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().StudentBalanceInsert, InitObject.GetUUID(), StudentID, UserID, CreateDate);
                                    DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Student LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally
                        {
                        }

                        // insert parent info

                        var ParentID             = InitObject.GetUUID();
                        var GuardianName         = GuardianNamePos == -1 ? string.Empty : dr[GuardianNamePos].ToString();
                        var GuardianMobileNo     = GuardianMobileNoPos == -1 ? string.Empty : dr[GuardianMobileNoPos].ToString();
                        var GuardianRelationship = GuardianRelationshipPos == -1 ? string.Empty : InitObject.GetRelationshipCodeByName(dr[GuardianRelationshipPos].ToString());
                        var GuardianEducation    = GuardianEducationPos == -1 ? string.Empty : dr[GuardianEducationPos].ToString();
                        var GuardianJob          = GuardianJobPos == -1 ? string.Empty : dr[GuardianJobPos].ToString();
                        var GuardianCompany      = GuardianCompanyPos == -1 ? string.Empty : dr[GuardianCompanyPos].ToString();

                        try
                        {
                            if (!string.IsNullOrEmpty(GuardianName))
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().ParentInsert, ParentID, StudentID, GuardianName, GuardianMobileNo, GuardianRelationship, "Y", UserID, GuardianEducation, GuardianJob, GuardianCompany);
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                Sql = string.Format(InitObject.GetScriptServiceInstance().ParentRefInsert, StudentID, ParentID, "Y");
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                Sql = string.Format(InitObject.GetScriptServiceInstance().PrivacyInsert, StudentID, ParentID, "Y");
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Student Guardion LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally
                        {
                        }

                        ParentID = InitObject.GetUUID();
                        var ParentName   = ParentNamePos == -1 ? string.Empty : dr[ParentNamePos].ToString();
                        var MobileNo     = MobileNoPos == -1 ? string.Empty : dr[MobileNoPos].ToString();
                        var Relationship = RelationshipPos == -1 ? string.Empty : InitObject.GetRelationshipCodeByName(dr[RelationshipPos].ToString());
                        var Education    = EducationPos == -1 ? string.Empty : dr[EducationPos].ToString();
                        var Job          = JobPos == -1 ? string.Empty : dr[JobPos].ToString();
                        var Company      = CompanyPos == -1 ? string.Empty : dr[CompanyPos].ToString();

                        try
                        {
                            if (!string.IsNullOrEmpty(ParentName))
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().ParentInsert, ParentID, StudentID, ParentName, MobileNo, Relationship, "N", UserID, Education, Job, Company);
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                Sql = string.Format(InitObject.GetScriptServiceInstance().ParentRefInsert, StudentID, ParentID, "N");
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                Sql = string.Format(InitObject.GetScriptServiceInstance().PrivacyInsert, StudentID, ParentID, "N");
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Student Parent LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally
                        {
                        }

                        // parent 3

                        ParentID = InitObject.GetUUID();
                        var ParentName3   = ParentName3Pos == -1 ? string.Empty : dr[ParentName3Pos].ToString();
                        var MobileNo3     = MobileNo3Pos == -1 ? string.Empty : dr[MobileNo3Pos].ToString();
                        var Relationship3 = Relationship3Pos == -1 ? string.Empty : InitObject.GetRelationshipCodeByName(dr[Relationship3Pos].ToString());
                        var Education3    = Education3Pos == -1 ? string.Empty : dr[Education3Pos].ToString();
                        var Job3          = Job3Pos == -1 ? string.Empty : dr[Job3Pos].ToString();
                        var Company3      = Company3Pos == -1 ? string.Empty : dr[Company3Pos].ToString();

                        try
                        {
                            if (!string.IsNullOrEmpty(ParentName3))
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().ParentInsert, ParentID, StudentID, ParentName3, MobileNo3, Relationship3, "N", UserID, Education3, Job3, Company3);
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                Sql = string.Format(InitObject.GetScriptServiceInstance().ParentRefInsert, StudentID, ParentID, "N");
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                Sql = string.Format(InitObject.GetScriptServiceInstance().PrivacyInsert, StudentID, ParentID, "N");
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Student Parent LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally
                        {
                        }


                        var StudentClassType   = "STUCLASSTYPE09";
                        var StudentClassStatus = "STUCLASSSTATUS03";

                        if (!string.IsNullOrWhiteSpace(ClassName))
                        {
                            var ClassId = string.Empty;
                            Sql = string.Format(InitObject.GetScriptServiceInstance().GetClassIdByYKN, AcadYear, KindergartenId, ClassName);
                            var dt = DBHelper.MySqlHelper.GetDataSet(BznsBase.GetConnectionString, BznsBase.GetCommandType, Sql, null).Tables[0];
                            if (dt.Rows.Count == 1)
                            {
                                foreach (DataRow row in dt.Rows)
                                {
                                    ClassId = row["class_id"].ToString();
                                }
                            }

                            try
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().StudentIntoClass, ClassId, StudentID, StudentClassType, UserID, StudentClassStatus, CreateDate);
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }
                            catch (Exception ex)
                            {
                                SysLog.Insert(new SysLogInfo(string.Concat("Import Student Join Class LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                            }
                            finally
                            {
                            }
                        }

                        Result = true;
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    Result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName, " - ", "Import Student Bzns")));
                    trans.Rollback();
                }
                finally
                {
                    trans = null;
                }
            }

            return(Result);
        }
        public bool InterestInsert(DataTable Classes, int ClassNamePos, int TypePos, int StartDatePos, int EndDatePos, int HoursPos, int PricePos, int AmountPos, int CategoryNamePos, int StatusPos, int ChargeTypePos, bool IsTry2Import)
        {
            var Result     = false;
            var CreateDate = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Classes.Rows)
                    {
                        try
                        {
                            var ClassName          = ClassNamePos == -1 ? string.Empty : dr[ClassNamePos].ToString().Trim();
                            var Type               = TypePos == -1 ? string.Empty : InitObject.GetDelayClassType(dr[TypePos].ToString().Trim());
                            var StartDate          = StartDatePos == -1 ? string.Empty : dr[StartDatePos].ToString().Trim();
                            var EndDate            = EndDatePos == -1 ? string.Empty : dr[EndDatePos].ToString().Trim();
                            var Hours              = HoursPos == -1 ? 0 : Convert.ToInt32(dr[HoursPos]);
                            var Price              = PricePos == -1 ? 0 : Convert.ToDecimal(dr[PricePos]);
                            var Amount             = AmountPos == -1 ? 0 : Convert.ToDecimal(dr[AmountPos]);
                            var CategoryName       = CategoryNamePos == -1 ? string.Empty : dr[CategoryNamePos].ToString().Trim();
                            var Status             = StatusPos == -1 ? string.Empty : InitObject.GetDelayClassStatus(dr[StatusPos].ToString().Trim());
                            var ChargeType         = ChargeTypePos == -1 ? string.Empty : InitObject.GetDelayChargeType(dr[ChargeTypePos].ToString().Trim());
                            var CourseCategoryInfo = new CategoryInfo();
                            var CategoryID         = InitObject.GetUUID();
                            var ClassId            = InitObject.GetUUID();
                            var Sql = string.Empty;


                            // Get category, if not exist create one in category table.

                            if (Type == "EXTRACLASS")
                            {
                                CourseCategoryInfo = GetCategoryInfo(CategoryName);
                                if (string.IsNullOrEmpty(CourseCategoryInfo.CategoryId))
                                {
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().CategoryInsert, CategoryID, CategoryName, BznsBase.KindergartenId, BznsBase.UserID, CreateDate);
                                    DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                    CourseCategoryInfo.CategoryId = CategoryID;
                                    CourseCategoryInfo.Name       = CategoryName;
                                }
                            }

                            // Create one interest class.

                            Sql = string.Format(InitObject.GetScriptServiceInstance().InterestInsert, ClassId, ClassName, Type, StartDate, EndDate, Hours, Price, Amount, (string.IsNullOrEmpty(CourseCategoryInfo.CategoryId)? string.Empty: CourseCategoryInfo.CategoryId), Status, BznsBase.KindergartenId, CreateDate, BznsBase.UserID, ChargeType);
                            DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat(dr["LogID"].ToString(), ex.Message.ToString()), SysLogType.ERROR, string.Concat(ModuleName, " - ", "InterestInsert", " - ", "Class")));
                        }
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    Result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName, " - ", "InterestInsert", " - ", "Class")));
                    trans.Rollback();
                }
            }


            return(Result);
        }
        public bool StudentInsert(DataTable Students, int StudentNoPos, int YearPos, int CourseNamePos, int ClassHoursPos, int MoneyPos, int PaidPos, int StartDatePos, int EndDatePos, bool IsTry2Import)
        {
            var Result     = false;
            var CreateDate = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Students.Rows)
                    {
                        try
                        {
                            int ret         = 0;
                            var Sql         = string.Empty;
                            var StudentNo   = StudentNoPos == -1 ? string.Empty : dr[StudentNoPos].ToString().Trim();
                            var CourseName  = CourseNamePos == -1 ? string.Empty : dr[CourseNamePos].ToString().Trim();
                            var Year        = YearPos == -1 ? string.Empty : dr[YearPos].ToString().Trim();
                            var CourseInfo  = GetCourseInfo(CourseName);
                            var StudentInfo = GetStudentInfo(StudentNo);
                            var YearInfo    = InitObject.GetYearByTitle(Year);


                            // Add student to class

                            var RecordId = InitObject.GetUUID();

                            if (!string.IsNullOrEmpty(CourseInfo.Id) && !string.IsNullOrEmpty(StudentInfo.StudentId))
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestStudentInsert, RecordId, CourseInfo.Id, StudentInfo.StudentId, 1);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            // Add finance bill and ref

                            var BillId     = InitObject.GetSysDate(true, true);
                            var BillStatus = "PAYMENTSTATE02";
                            var BillMonth  = DateTime.Now.ToString("yyyy-MM");
                            var ClassHours = ClassHoursPos == -1 ? 0 : Convert.ToInt32(dr[ClassHoursPos]);
                            var Money      = MoneyPos == -1 ? 0 : Convert.ToDecimal(dr[MoneyPos]);
                            var BillType   = 1;
                            var BillAlert  = "N";
                            var BillEffect = "Y";
                            var Paid       = PaidPos == -1 ? "N" : "Y";
                            var PayMoney   = Money;

                            var RefId       = InitObject.GetUUID();
                            var StartDate   = StartDatePos == -1 ? CourseInfo.StartDate.ToString("yyyy-MM-dd") : Convert.ToString(dr[StartDatePos]);
                            var EndDate     = EndDatePos == -1 ? CourseInfo.EndDate.ToString("yyyy-MM-dd") : Convert.ToString(dr[EndDatePos]);
                            var RefBillType = "EXTRACLASS";
                            var RefBillNo   = InitObject.GetBillNo(StartDate, string.Empty);
                            var RefStatus   = "PAYMENTSTATE02";

                            #region Create student finance order info

                            if (ret > 0 && Money > 0)
                            {
                                // insert into bill

                                ret = 0;
                                if (Paid == "N")
                                {
                                    PayMoney = new decimal(0);
                                }
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestBillInsert, BillId, StudentInfo.StudentId, YearInfo.YearID, "", BillStatus, BillMonth, Money, PayMoney, BillType, BillAlert, BillEffect, CreateDate);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                // insert into bill ref

                                if (ret > 0)
                                {
                                    ret = 0;
                                    if (Paid == "N")
                                    {
                                        RefStatus = "PAYMENTSTATE01";
                                    }
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().InterestBillRefInsert, RefId, BillId, RefBillType, RefBillNo, CourseInfo.Id, BillMonth, ClassHours, CourseInfo.Hours, StartDate, EndDate, RefStatus, Money, PayMoney, CreateDate, CreateDate, BznsBase.UserID);
                                    ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                }
                            }

                            #endregion

                            #region Create student pay info

                            var PayId     = InitObject.GetUUID();
                            var PayWay    = InitObject.GetPaymentType(BznsBase.PaymentType);
                            var PayInfo   = InitObject.GetPaymentInfo();
                            var PayStatus = "PAYMENTSTATE02";

                            var PayRefId     = InitObject.GetUUID();
                            var PayRefStatus = "0";


                            if (ret > 0)
                            {
                                ret = 0;
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestBillPaymentInsert, PayId, BillId, RefBillNo, Money, PayWay, CreateDate, PayInfo.PaymentNo, PayInfo.PaymentNo, PayStatus, BznsBase.UserID, CreateDate);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                if (ret > 0)
                                {
                                    ret = 0;
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().InterestBillPaymentRefInsert, PayRefId, RefId, PayId, Money, PayStatus, CreateDate);
                                    ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                }
                            }

                            #endregion

                            #region Add money to account and balance

                            var StudentBalanceInfo = new StudentBalanceInfo();
                            var AccountId          = InitObject.GetUUID();
                            Sql = string.Format(InitObject.GetScriptServiceInstance().GetStudentBalanceListByStudentId, StudentInfo.StudentId);
                            var dt = DBHelper.MySqlHelper.GetDataSet(BznsBase.GetConnectionString, BznsBase.GetCommandType, Sql, null).Tables[0];

                            if (dt.Rows.Count > 0)
                            {
                                StudentBalanceInfo.BalanceId = dt.Rows[0]["balance_id"].ToString();
                                StudentBalanceInfo.StudentId = dt.Rows[0]["student_id"].ToString();
                                StudentBalanceInfo.Total     = Convert.ToDecimal(dt.Rows[0]["balance_total"]);
                                StudentBalanceInfo.Income    = Convert.ToDecimal(dt.Rows[0]["balance_income"]);
                            }

                            // Add into student balance account.

                            if (ret > 0 && !string.IsNullOrEmpty(StudentBalanceInfo.BalanceId))
                            {
                                ret = 0;
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestStudentBalanceAccountInsert, AccountId, StudentBalanceInfo.BalanceId, StudentInfo.StudentId, Money, "EXTRACLASS", BznsBase.UserID, CreateDate);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            // Add into delay subject account

                            var DelayId = InitObject.GetUUID();

                            if (ret > 0)
                            {
                                ret = 0;
                                Sql = string.Format(InitObject.GetScriptServiceInstance().DelayInsert, DelayId, AccountId, StudentInfo.StudentId, YearInfo.YearID, Money, "Y", Money, RefId, BznsBase.UserID, CreateDate);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            // Add into student balance

                            if (ret > 0)
                            {
                                ret = 0;
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestBalanceUpdate, Money, Money, StudentInfo.StudentId);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            // Add into subject log

                            if (ret > 0)
                            {
                                ret = 0;
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestSubjectLogInsert, StudentInfo.StudentId, "EXTRACLASS", DelayId, "REALGROWTH", "延时服务初始化数据导入", Money, CreateDate, RefId, PayRefId);
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            // Add into balance log

                            if (ret > 0)
                            {
                                ret = 0;
                                Sql = string.Format(InitObject.GetScriptServiceInstance().InterestStudentBalanceLogInsert, "TRADETYPE01", StudentInfo.StudentId, Money, CreateDate, "EXTRACLASS", "N", StudentBalanceInfo.BalanceId, BillId, "延时服务初始化数据导入");
                                ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            #endregion
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat(dr[StudentNoPos].ToString(), ex.Message.ToString()), SysLogType.ERROR, string.Concat(ModuleName, " - ", "Interest Student Insert", " - ", "Student")));
                        }
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    Result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName, " - ", "Interest Student Insert", " - ", "Student")));
                    trans.Rollback();
                }
            }

            return(Result);
        }
示例#17
0
        public bool InsertTeacher(bool IsTry2Import, DataTable Teachers, int NamePos, int LastNamePos, int FirstNamePos, int SexPos, int NationalityPos, int NationPos, int IDCardTypePos, int IDCardNoPos, int BirthdayPos, int MobileNoPos, int EmailAddressPos, int IsPreEduPos, int ForeignNationalityPos, int TeacherLevelPos, int EduQualificationPos, int ProfessionPos, int UniversityPos, int ClassIdPos, int KindergartenIdPos, int AccountPos)
        {
            var result     = false;
            var Sql        = string.Empty;
            var CreateDate = InitObject.GetSysDate();

            using (MySqlConnection conn = new MySqlConnection(BznsBase.GetConnectionString))
            {
                MySqlTransaction trans = null;
                conn.Open();
                trans = conn.BeginTransaction();

                try
                {
                    foreach (DataRow dr in Teachers.Rows)
                    {
                        var TeacherID = InitObject.GetUUID();

                        var TeacherName        = NamePos == -1 ? string.Empty : dr[NamePos].ToString().Trim();
                        var LastName           = LastNamePos == -1 ? string.Empty : dr[LastNamePos].ToString().Trim();
                        var FirstName          = FirstNamePos == -1 ? string.Empty : dr[FirstNamePos].ToString().Trim();
                        var Sex                = SexPos == -1 ? string.Empty : InitObject.GetSexByName(dr[SexPos].ToString().Trim());
                        var Nationality        = NationalityPos == -1 ? string.Empty : dr[NationalityPos].ToString().Trim();
                        var Nation             = NationPos == -1 ? string.Empty : InitObject.GetNationCodeByName(dr[NationPos].ToString().Trim());
                        var IDCardType         = IDCardTypePos == -1 ? string.Empty : InitObject.GetIdType(dr[IDCardTypePos].ToString().Trim());
                        var IDCardNo           = IDCardNoPos == -1 ? string.Empty : dr[IDCardNoPos].ToString().Trim();
                        var Birthday           = BirthdayPos == -1 ? string.Empty : dr[BirthdayPos].ToString().Trim();
                        var MobileNo           = MobileNoPos == -1 ? string.Empty : dr[MobileNoPos].ToString().Trim();
                        var EmailAddress       = EmailAddressPos == -1 ? string.Empty : dr[EmailAddressPos].ToString().Trim();
                        var IsPreEdu           = IsPreEduPos == -1 ? string.Empty : dr[IsPreEduPos].ToString().Trim();
                        var ForeignNationality = ForeignNationalityPos == -1 ? string.Empty : dr[ForeignNationalityPos].ToString().Trim();
                        var TeacherLevel       = TeacherLevelPos == -1 ? string.Empty : InitObject.GetTeacherLevel(dr[TeacherLevelPos].ToString().Trim());
                        var EduQualification   = EduQualificationPos == -1 ? string.Empty : InitObject.GetEducationCodeByName(dr[EduQualificationPos].ToString().Trim());
                        var Profession         = ProfessionPos == -1 ? string.Empty : dr[ProfessionPos].ToString().Trim();
                        var University         = UniversityPos == -1 ? string.Empty : dr[UniversityPos].ToString().Trim();
                        var iSex               = 0;
                        var ClassId            = ClassIdPos == -1 ? string.Empty : dr[ClassIdPos].ToString().Trim();
                        var KindergartenId     = KindergartenIdPos == -1 ? string.Empty : dr[KindergartenIdPos].ToString().Trim();
                        var Account            = AccountPos == -1 ? string.Empty : dr[AccountPos].ToString().Trim();


                        try
                        {
                            if (string.IsNullOrEmpty(KindergartenId))
                            {
                                KindergartenId = BznsBase.KindergartenId;
                            }

                            Sql = string.Format(InitObject.GetScriptServiceInstance().TeacherInsert, TeacherID, KindergartenId, TeacherName, LastName, FirstName, Sex, Nationality, Nation, IDCardType, IDCardNo, Birthday, Account, EmailAddress, IsPreEdu, ForeignNationality, TeacherLevel, EduQualification, Profession, University, BznsBase.UserID, CreateDate);
                            var ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                            if (!string.IsNullOrEmpty(ClassId) && ret > 0)
                            {
                                Sql = string.Format(InitObject.GetScriptServiceInstance().TeacherClassInsert, ClassId, TeacherID, "STAFFTYPE02", 'N');
                                DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                            }

                            if (ret > 0)
                            {
                                if (Sex == "M")
                                {
                                    iSex = 1;
                                }

                                Sql = string.Format(InitObject.GetScriptServiceInstance().UserInsert, TeacherID, Account, BznsBase.UserPassword, BznsBase.UserPasswordSalt, TeacherName, MobileNo, EmailAddress, KindergartenId, BznsBase.BrandID, iSex);

                                if (DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null) > 0)
                                {
                                    // 8daa29e88498480aad68683c361a451e 保育员
                                    Sql = string.Format(InitObject.GetScriptServiceInstance().RoleInsert, InitObject.GetUUID(), TeacherID, "ed40b872ec1a48dea57819e58fbff1a7");
                                    DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);

                                    Sql = string.Format(InitObject.GetScriptServiceInstance().UserKindergartenInsert, TeacherID, KindergartenId);
                                    ret = DBHelper.MySqlHelper.ExecuteNonQuery(trans, BznsBase.GetCommandType, Sql, null);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SysLog.Insert(new SysLogInfo(string.Concat("Import Teacher LogID:", dr["LogID"].ToString(), " Error Message:", ex.Message), SysLogType.ERROR, ModuleName));
                        }
                        finally
                        {
                        }
                    }

                    if (IsTry2Import)
                    {
                        trans.Rollback();
                    }
                    else
                    {
                        trans.Commit();
                    }

                    result = true;
                }
                catch (Exception ex)
                {
                    SysLog.Insert(new SysLogInfo(ex.Message.ToString(), SysLogType.ERROR, string.Concat(ModuleName, " - ", "Import Teacher Bzns")));
                    trans.Rollback();
                }
                finally
                {
                    trans = null;
                }
            }


            return(result);
        }