Ejemplo n.º 1
0
    public string getUnitAutoNumber(string FieldName, string Unit)
    {
        CaseDataBase sDB = new CaseDataBase();
        string stuIDName = "";
        if (Unit.Length == 0)
        {
            StaffDataBase StaffDB = new StaffDataBase();
            List<string> CreateFileName = StaffDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
            Unit = CreateFileName[2];
        }
        int stuNumber = 4;
        if (FieldName == "StaffDB_")
        {
            stuNumber = 3;
        }
        string StudentDBitem = "";
        if (FieldName == "StudentDB_")
        {
            StudentDBitem = "0";
        }
        int AutoNumber = int.Parse(sDB.getUnitAutoNumber(FieldName + Unit));
        AutoNumber = AutoNumber + 1;
        stuIDName = Unit + AutoNumber.ToString().PadLeft(stuNumber, '0') + StudentDBitem;

        if (FieldName == "Volunteer_")
        {
            stuIDName = "62" + Unit + AutoNumber.ToString().PadLeft(3, '0');
        }

        return stuIDName;
    }
    public string[] createPropertyRecordData(CreatePropertyRecord propertyRecordData)
    {
        string[] returnValue = new string[2];
        returnValue[0] = "0";
        returnValue[1] = "0";
        DataBase Base = new DataBase();
        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                StaffDataBase sDB = new StaffDataBase();
                List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
                Sqlconn.Open();
                string sql = "INSERT INTO PropertyRecord (WriteDate, Unit, PropertyState, PropertyAddImpairment, PropertyChangeState, PropertyID, " +
                    "Code, ApplyID, Category, PropertyName, Label, ItemUnit, Quantity, Fitting, Location, Custody, ScrapDate, " +
                    "Summons, Receipt, Accounting, RecordedDate, OutDate, FundSource, FundSourceAssist, FundSourceDonate, PurchaseDate, " +
                    "Residual, PurchaseSource, ExpirationDate, Price, Depreciation, SinceFundraising, Procurement, Grants, Remark, " +
                    "CreateFileBy, CreateFileDate, UpFileBy, UpFileDate, isDeleted) VALUES " +
                    "(@WriteDate, @Unit, @PropertyState, @PropertyAddImpairment, @PropertyChangeState, @PropertyID, " +
                    "@Code, @ApplyID, @Category, @PropertyName, @Label, @ItemUnit, @Quantity, @Fitting, @Location, @Custody, @ScrapDate, " +
                    "@Summons, @Receipt, @Accounting, @RecordedDate, @OutDate, @FundSource, @FundSourceAssist, @FundSourceDonate, @PurchaseDate, " +
                    "@Residual, @PurchaseSource, @ExpirationDate, @Price, @Depreciation, @SinceFundraising, @Procurement, @Grants, @Remark, " +
                    "@CreateFileBy, (getDate()), @UpFileBy, (getDate()), 0)";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@WriteDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.fillInDate);
                cmd.Parameters.Add("@Unit", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(CreateFileName[2]);
                cmd.Parameters.Add("@PropertyState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyStatus);
                cmd.Parameters.Add("@PropertyAddImpairment", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyChange);
                cmd.Parameters.Add("@PropertyChangeState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.changeStatus);
                cmd.Parameters.Add("@PropertyID", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyID);
                cmd.Parameters.Add("@Code", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCode);
                cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.applyID);
                cmd.Parameters.Add("@Category", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCategory);
                cmd.Parameters.Add("@PropertyName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyName);
                cmd.Parameters.Add("@Label", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyLabel);
                cmd.Parameters.Add("@ItemUnit", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyUnit);
                cmd.Parameters.Add("@Quantity", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyQuantity);
                cmd.Parameters.Add("@Fitting", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyFitting);
                cmd.Parameters.Add("@Location", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyLocation);
                cmd.Parameters.Add("@Custody", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCustody);
                cmd.Parameters.Add("@ScrapDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.stopDate);
                cmd.Parameters.Add("@Summons", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertySummons);
                cmd.Parameters.Add("@Receipt", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyReceipt);
                cmd.Parameters.Add("@Accounting", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyAccounting);
                cmd.Parameters.Add("@RecordedDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.inputDate);
                cmd.Parameters.Add("@OutDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.outputDate);
                cmd.Parameters.Add("@FundSource", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.fundSource);
                cmd.Parameters.Add("@FundSourceAssist", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.fundAssist);
                cmd.Parameters.Add("@FundSourceDonate", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.fundDonate);
                cmd.Parameters.Add("@PurchaseDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.buyDate);
                cmd.Parameters.Add("@Residual", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Remnants);
                cmd.Parameters.Add("@PurchaseSource", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.buySource);
                cmd.Parameters.Add("@ExpirationDate", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.userYear);
                cmd.Parameters.Add("@Price", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyPrice);
                cmd.Parameters.Add("@Depreciation", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Depreciation);
                cmd.Parameters.Add("@SinceFundraising", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.selfFunds);
                cmd.Parameters.Add("@Procurement", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.Purchaser);
                cmd.Parameters.Add("@Grants", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.Grant);
                cmd.Parameters.Add("@Remark", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Remark);
                cmd.Parameters.Add("@CreateFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);

                returnValue[0] = cmd.ExecuteNonQuery().ToString();
                if (returnValue[0] != "0")
                {
                    string FieldName = "PropertDB_" + CreateFileName[2];
                    sql = "SELECT IDENT_CURRENT('PropertyRecord') AS pID " +
                          "UPDATE AutomaticNumberTable SET " + FieldName + "=" + FieldName + "+1 WHERE ID=1 ";
                    cmd = new SqlCommand(sql, Sqlconn);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        returnValue[1] = dr["pID"].ToString();
                    }
                    dr.Close();

                    /*sql = "SELECT Count(*) AS QCOUNT FROM PropertyRecord WHERE isDeleted=0";
                    cmd = new SqlCommand(sql, Sqlconn);
                    string stuNumber = cmd.ExecuteScalar().ToString();
                    string stuIDName = CreateFileName[2] + stuNumber.PadLeft(4, '0');*/
                    CaseDataBase SDB = new CaseDataBase();
                    string stuNumber = SDB.getUnitAutoNumber(FieldName);
                    string stuIDName = CreateFileName[2] + stuNumber.PadLeft(4, '0');

                    sql = "UPDATE PropertyRecord SET Code=(@Code), UpFileBy=@UpFileBy, UpFileDate=(getDate()) WHERE RecordID=(@RecordID) AND isDeleted=0";
                    cmd = new SqlCommand(sql, Sqlconn);
                    cmd.Parameters.Add("@RecordID", SqlDbType.BigInt).Value = Chk.CheckStringtoInt64Function(returnValue[1]);
                    cmd.Parameters.Add("@Code", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(stuIDName);
                    cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                    returnValue[0] = cmd.ExecuteNonQuery().ToString();
                }
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue[0] = "-1";
                returnValue[1] = e.Message.ToString();
            }
        }
        return returnValue;
    }
Ejemplo n.º 3
0
    public string[] CreateUserMemberData(CreateStaff StaffData)
    {
        string[] returnValue = new string[3];
            returnValue[0] = "0";
            returnValue[1] = "0";
            returnValue[2] = "0";
            DataBase Base = new DataBase();
            using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
            {
                try
                {
                    List<string> CreateFileName = this.getStaffDataName(HttpContext.Current.User.Identity.Name);
                    Sqlconn.Open();
                    string sql = "INSERT INTO StaffDatabase (Unit, StaffID, StaffName, AppointmentDate, ResignationDate, WorkItem, JobCapacity, JobGrade, StaffIdentity, " +
                        "StaffAvatar, Hometown, Birthday, sex, Marriage, AddressZip1, AddressCity1, AddressOther1, AddressZip2, AddressCity2, AddressOther2, TelDaytime, "+
                        "TelNight, Phone, Email, " +
                        "UrgentContactName, UrgentContactAddress, UrgentContactTel, DoctorSchoolName, DoctorDepartment, DoctorSince, DoctorUntil, DoctorState, MasterSchoolName, " +
                        "MasterDepartment, MasterSince, MasterUntil, MasterState, UniversitySchoolName, UniversityDepartment, UniversitySince, UniversityUntil, UniversityState, " +
                        "VocationalSchoolName, VocationalDepartment, VocationalSince, VocationalUntil, VocationalState, Experience1Since, Experience1Until, Experience1Company, " +
                        "Experience1Post, Experience1Salary, Experience1Prove, Experience1Director, Experience1DirectorName, Experience2Since, Experience2Until, " +
                        "Experience2Company, Experience2Post, Experience2Salary, Experience2Prove, Experience2Director, Experience2DirectorName, Experience3Since, " +
                        "Experience3Until, Experience3Company, Experience3Post, Experience3Salary, Experience3Prove, Experience3Director, Experience3DirectorName, " +
                        "Experience4Since, Experience4Until, Experience4Company, Experience4Post, Experience4Salary, Experience4Prove, Experience4Director, " +
                        "Experience4DirectorName, Family1Title, Family1Name, Family1Age, Family1Profession, Family2Title, Family2Name, Family2Age, Family2Profession, " +
                        "Family3Title, Family3Name, Family3Age, Family3Profession, Family4Title, Family4Name, Family4Age, Family4Profession, Family5Title, " +
                        "Family5Name, Family5Age, Family5Profession, Family6Title, Family6Name, Family6Age, Family6Profession, GuarantorName, GuarantorUnit, " +
                        "GuarantorPost, GuarantorRelationship, GuarantorContact, GuarantorContactTime, CandidatesMessage, MessageExplain, Language1Name, Language1Listen, " +
                        "Language1Say, Language1Read, Language1Write, Language2Name, Language2Listen, Language2Say, Language2Read, Language2Write, Language3Name, " +
                        "Language3Listen, Language3Say, Language3Read, Language3Write, ExpertiseSkill1, ExpertiseSkill1License, ExpertiseSkill1Progression, " +
                        "ExpertiseSkill1GetUnit, ExpertiseSkill1GetDate, ExpertiseSkill1ValidDate, ExpertiseSkill2, ExpertiseSkill2License, ExpertiseSkill2Progression, " +
                        "ExpertiseSkill2GetUnit, ExpertiseSkill2GetDate, ExpertiseSkill2ValidDate, ExpertiseSkill3, ExpertiseSkill3License, ExpertiseSkill3Progression, " +
                        "ExpertiseSkill3GetUnit, ExpertiseSkill3GetDate, ExpertiseSkill3ValidDate, ExpertiseSkill4, ExpertiseSkill4License, ExpertiseSkill4Progression, " +
                        "TrialStart,TrialEnd,DealStart,DealEnd,CardNum," + //by WHO
                        "ExpertiseSkill4GetUnit, ExpertiseSkill4GetDate, ExpertiseSkill4ValidDate, Disease, DiseaseExplain, FileDate, CreateFileBy, UpFileBy, UpFileDate)" +

                        "VALUES (@Unit, @StaffID, @StaffName, @AppointmentDate, @ResignationDate, @WorkItem, @JobCapacity, @JobGrade, @StaffIdentity, " +
                        "@StaffAvatar, @Hometown, @Birthday, @sex, @Marriage, @AddressZip1, @AddressCity1, " +
                        "@AddressOther1, @AddressZip2, @AddressCity2, @AddressOther2, @TelDaytime, @TelNight, @Phone, @Email, " +
                        "@UrgentContactName, @UrgentContactAddress, @UrgentContactTel, @DoctorSchoolName, @DoctorDepartment, @DoctorSince, @DoctorUntil, @DoctorState, @MasterSchoolName, " +
                        "@MasterDepartment, @MasterSince, @MasterUntil, @MasterState, @UniversitySchoolName, @UniversityDepartment, @UniversitySince, @UniversityUntil, @UniversityState, " +
                        "@VocationalSchoolName, @VocationalDepartment, @VocationalSince, @VocationalUntil, @VocationalState, @Experience1Since, @Experience1Until, @Experience1Company, " +
                        "@Experience1Post, @Experience1Salary, @Experience1Prove, @Experience1Director, @Experience1DirectorName, @Experience2Since, @Experience2Until, " +
                        "@Experience2Company, @Experience2Post, @Experience2Salary, @Experience2Prove, @Experience2Director, @Experience2DirectorName, @Experience3Since, " +
                        "@Experience3Until, @Experience3Company, @Experience3Post, @Experience3Salary, @Experience3Prove, @Experience3Director, @Experience3DirectorName, " +
                        "@Experience4Since, @Experience4Until, @Experience4Company, @Experience4Post, @Experience4Salary, @Experience4Prove, @Experience4Director, " +
                        "@Experience4DirectorName, @Family1Title, @Family1Name, @Family1Age, @Family1Profession, @Family2Title, @Family2Name, @Family2Age, @Family2Profession, " +
                        "@Family3Title, @Family3Name, @Family3Age, @Family3Profession, @Family4Title, @Family4Name, @Family4Age, @Family4Profession, @Family5Title, " +
                        "@Family5Name, @Family5Age, @Family5Profession, @Family6Title, @Family6Name, @Family6Age, @Family6Profession, @GuarantorName, @GuarantorUnit, " +
                        "@GuarantorPost, @GuarantorRelationship, @GuarantorContact, @GuarantorContactTime, @CandidatesMessage, @MessageExplain, @Language1Name, @Language1Listen, " +
                        "@Language1Say, @Language1Read, @Language1Write, @Language2Name, @Language2Listen, @Language2Say, @Language2Read, @Language2Write, @Language3Name, " +
                        "@Language3Listen, @Language3Say, @Language3Read, @Language3Write, @ExpertiseSkill1, @ExpertiseSkill1License, @ExpertiseSkill1Progression, " +
                        "@ExpertiseSkill1GetUnit, @ExpertiseSkill1GetDate, @ExpertiseSkill1ValidDate, @ExpertiseSkill2, @ExpertiseSkill2License, @ExpertiseSkill2Progression, " +
                        "@ExpertiseSkill2GetUnit, @ExpertiseSkill2GetDate, @ExpertiseSkill2ValidDate, @ExpertiseSkill3, @ExpertiseSkill3License, @ExpertiseSkill3Progression, " +
                        "@ExpertiseSkill3GetUnit, @ExpertiseSkill3GetDate, @ExpertiseSkill3ValidDate, @ExpertiseSkill4, @ExpertiseSkill4License, @ExpertiseSkill4Progression, " +
                        "@TrialStart,@TrialEnd,@DealStart,@DealEnd,@CardNum," + //by WHO
                        "@ExpertiseSkill4GetUnit, @ExpertiseSkill4GetDate, @ExpertiseSkill4ValidDate, @Disease, @DiseaseExplain, @FileDate,@CreateFileBy, @UpFileBy, (getDate())) ";

                    SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                    cmd.Parameters.Add("@Unit", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.unit);
                    cmd.Parameters.Add("@StaffID", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.staffID);
                    cmd.Parameters.Add("@StaffName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.staffName);
                    cmd.Parameters.Add("@AppoIntmentDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.officeDate);
                    cmd.Parameters.Add("@ResignationDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.resignDate);
                    cmd.Parameters.Add("@WorkItem", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.applyJob);
                    cmd.Parameters.Add("@JobCapacity", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.jobTitle);
                    cmd.Parameters.Add("@JobGrade", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.jobLevel);
                    cmd.Parameters.Add("@StaffIdentity", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.staffTWID);
                    cmd.Parameters.Add("@StaffAvatar", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.staffPhoto);
                    cmd.Parameters.Add("@Hometown", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.comeCity);
                    cmd.Parameters.Add("@Birthday", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.staffbirthday);
                    cmd.Parameters.Add("@sex", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.staffsex);
                    cmd.Parameters.Add("@Marriage", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.marriage);
                    cmd.Parameters.Add("@AddressZip1", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.censusAddressZip);
                    cmd.Parameters.Add("@AddressCity1", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.censusCity);
                    cmd.Parameters.Add("@AddressOther1", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.censusAddress);
                    cmd.Parameters.Add("@AddressZip2", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.addressZip);
                    cmd.Parameters.Add("@AddressCity2", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.addressCity);
                    cmd.Parameters.Add("@AddressOther2", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.address);
                    cmd.Parameters.Add("@TelDaytime", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.TDaytime);
                    cmd.Parameters.Add("@TelNight", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.TNight);
                    cmd.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Phone);
                    cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.staffemail);
                    cmd.Parameters.Add("@UrgentContactName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.EmergencyName);
                    cmd.Parameters.Add("@UrgentContactAddress", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.EmergencyAddress);
                    cmd.Parameters.Add("@UrgentContactTel", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.EmergencyPhone);
                    cmd.Parameters.Add("@DoctorSchoolName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.DSchoolName);
                    cmd.Parameters.Add("@DoctorDepartment", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.DDepartment);
                    cmd.Parameters.Add("@DoctorSince", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.DSince);
                    cmd.Parameters.Add("@DoctorUntil", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.DUntil);
                    cmd.Parameters.Add("@DoctorState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.study1);
                    cmd.Parameters.Add("@MasterSchoolName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.MSchoolName);
                    cmd.Parameters.Add("@MasterDepartment", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.MDepartment);
                    cmd.Parameters.Add("@MasterSince", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.MSince);
                    cmd.Parameters.Add("@MasterUntil", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.MUntil);
                    cmd.Parameters.Add("@MasterState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.study2);
                    cmd.Parameters.Add("@UniversitySchoolName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.USchoolName);
                    cmd.Parameters.Add("@UniversityDepartment", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.UDepartment);
                    cmd.Parameters.Add("@UniversitySince", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.USince);
                    cmd.Parameters.Add("@UniversityUntil", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.UUntil);
                    cmd.Parameters.Add("@UniversityState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.study3);
                    cmd.Parameters.Add("@VocationalSchoolName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.VSchoolName);
                    cmd.Parameters.Add("@VocationalDepartment", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.VDepartment);
                    cmd.Parameters.Add("@VocationalSince", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.VSince);
                    cmd.Parameters.Add("@VocationalUntil", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.VUntil);
                    cmd.Parameters.Add("@VocationalState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.study4);
                    cmd.Parameters.Add("@Experience1Since", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateSince1);
                    cmd.Parameters.Add("@Experience1Until", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateUntil1);
                    cmd.Parameters.Add("@Experience1Company", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JCname1);
                    cmd.Parameters.Add("@Experience1Post", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jposition1);
                    cmd.Parameters.Add("@Experience1Salary", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jsalary1);
                    cmd.Parameters.Add("@Experience1Prove", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.prove1);
                    cmd.Parameters.Add("@Experience1Director", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitle1);
                    cmd.Parameters.Add("@Experience1DirectorName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitleName1);
                    cmd.Parameters.Add("@Experience2Since", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateSince2);
                    cmd.Parameters.Add("@Experience2Until", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateUntil2);
                    cmd.Parameters.Add("@Experience2Company", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JCname2);
                    cmd.Parameters.Add("@Experience2Post", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jposition2);
                    cmd.Parameters.Add("@Experience2Salary", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jsalary2);
                    cmd.Parameters.Add("@Experience2Prove", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.prove2);
                    cmd.Parameters.Add("@Experience2Director", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitle2);
                    cmd.Parameters.Add("@Experience2DirectorName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitleName2);
                    cmd.Parameters.Add("@Experience3Since", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateSince3);
                    cmd.Parameters.Add("@Experience3Until", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateUntil3);
                    cmd.Parameters.Add("@Experience3Company", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JCname3);
                    cmd.Parameters.Add("@Experience3Post", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jposition3);
                    cmd.Parameters.Add("@Experience3Salary", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jsalary3);
                    cmd.Parameters.Add("@Experience3Prove", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.prove3);
                    cmd.Parameters.Add("@Experience3Director", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitle3);
                    cmd.Parameters.Add("@Experience3DirectorName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitleName3);
                    cmd.Parameters.Add("@Experience4Since", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateSince4);
                    cmd.Parameters.Add("@Experience4Until", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JDateUntil4);
                    cmd.Parameters.Add("@Experience4Company", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JCname4);
                    cmd.Parameters.Add("@Experience4Post", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jposition4);
                    cmd.Parameters.Add("@Experience4Salary", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.Jsalary4);
                    cmd.Parameters.Add("@Experience4Prove", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.prove4);
                    cmd.Parameters.Add("@Experience4Director", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitle4);
                    cmd.Parameters.Add("@Experience4DirectorName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.JTitleName4);
                    cmd.Parameters.Add("@Family1Title", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[0][0]);
                    cmd.Parameters.Add("@Family1Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[0][1]);
                    cmd.Parameters.Add("@Family1Age", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.FamilyStatu[0][2]);
                    cmd.Parameters.Add("@Family1Profession", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[0][3]);
                    cmd.Parameters.Add("@Family2Title", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[1][0]);
                    cmd.Parameters.Add("@Family2Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[1][1]);
                    cmd.Parameters.Add("@Family2Age", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.FamilyStatu[1][2]);
                    cmd.Parameters.Add("@Family2Profession", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[1][3]);
                    cmd.Parameters.Add("@Family3Title", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[2][0]);
                    cmd.Parameters.Add("@Family3Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[2][1]);
                    cmd.Parameters.Add("@Family3Age", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.FamilyStatu[2][2]);
                    cmd.Parameters.Add("@Family3Profession", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[2][3]);
                    cmd.Parameters.Add("@Family4Title", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[3][0]);
                    cmd.Parameters.Add("@Family4Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[3][1]);
                    cmd.Parameters.Add("@Family4Age", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.FamilyStatu[3][2]);
                    cmd.Parameters.Add("@Family4Profession", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[3][3]);
                    cmd.Parameters.Add("@Family5Title", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[4][0]);
                    cmd.Parameters.Add("@Family5Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[4][1]);
                    cmd.Parameters.Add("@Family5Age", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.FamilyStatu[4][2]);
                    cmd.Parameters.Add("@Family5Profession", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[4][3]);
                    cmd.Parameters.Add("@Family6Title", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[5][0]);
                    cmd.Parameters.Add("@Family6Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[5][1]);
                    cmd.Parameters.Add("@Family6Age", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.FamilyStatu[5][2]);
                    cmd.Parameters.Add("@Family6Profession", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.FamilyStatu[5][3]);
                    cmd.Parameters.Add("@GuarantorName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.bailName);
                    cmd.Parameters.Add("@GuarantorUnit", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.bailUnit);
                    cmd.Parameters.Add("@GuarantorPost", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.bailJob);
                    cmd.Parameters.Add("@GuarantorRelationship", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.bailRelationship);
                    cmd.Parameters.Add("@GuarantorContact", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.bailContact);
                    cmd.Parameters.Add("@GuarantorContactTime", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.bailContactTime);
                    cmd.Parameters.Add("@CandidatesMessage", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.recruited);
                    cmd.Parameters.Add("@MessageExplain", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.recruitedText);
                    cmd.Parameters.Add("@Language1Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.langAbility1);
                    cmd.Parameters.Add("@Language1Listen", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langL1);
                    cmd.Parameters.Add("@Language1Say", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langS1);
                    cmd.Parameters.Add("@Language1Read", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langR1);
                    cmd.Parameters.Add("@Language1Write", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langW1);
                    cmd.Parameters.Add("@Language2Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.langAbility2);
                    cmd.Parameters.Add("@Language2Listen", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langL2);
                    cmd.Parameters.Add("@Language2Say", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langS2);
                    cmd.Parameters.Add("@Language2Read", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langR2);
                    cmd.Parameters.Add("@Language2Write", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langW2);
                    cmd.Parameters.Add("@Language3Name", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.langAbility3);
                    cmd.Parameters.Add("@Language3Listen", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langL3);
                    cmd.Parameters.Add("@Language3Say", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langS3);
                    cmd.Parameters.Add("@Language3Read", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langR3);
                    cmd.Parameters.Add("@Language3Write", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.langW3);

                    for (int i = 0; i < StaffData.SpecialtySkill.Count; i++)
                    {
                        cmd.Parameters.Add("@ExpertiseSkill" + (i + 1), SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.SpecialtySkill[i][0]);
                        cmd.Parameters.Add("@ExpertiseSkill" + (i + 1) + "License", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.SpecialtySkill[i][1]);
                        cmd.Parameters.Add("@ExpertiseSkill" + (i + 1) + "Progression", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.SpecialtySkill[i][2]);
                        cmd.Parameters.Add("@ExpertiseSkill" + (i + 1) + "GetUnit", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.SpecialtySkill[i][3]);
                        cmd.Parameters.Add("@ExpertiseSkill" + (i + 1) + "GetDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.SpecialtySkill[i][4]);
                        cmd.Parameters.Add("@ExpertiseSkill" + (i + 1) + "ValidDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.SpecialtySkill[i][5]);

                    }
                    cmd.Parameters.Add("@TrialStart", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.TrialStart);//BY WHO
                    cmd.Parameters.Add("@TrialEnd", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.TrialEnd);
                    cmd.Parameters.Add("@DealStart", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.DealStart);
                    cmd.Parameters.Add("@DealEnd", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.DealEnd);
                    cmd.Parameters.Add("@CardNum", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.CardNum);//BY WHO

                    cmd.Parameters.Add("@FileDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StaffData.fillInDate);
                    cmd.Parameters.Add("@Disease", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StaffData.disease);
                    cmd.Parameters.Add("@DiseaseExplain", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StaffData.diseaseText);
                    cmd.Parameters.Add("@CreateFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                    cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                    returnValue[0] = cmd.ExecuteNonQuery().ToString();

                    if (returnValue[0] != "0")
                    {
                        string FieldName = "StaffDB_" + StaffData.unit;
                        Int64 Column = 0;
                        sql = "select IDENT_CURRENT('StaffDatabase') AS cID "+
                              "UPDATE AutomaticNumberTable SET " + FieldName + "=" + FieldName + "+1 WHERE ID=1 ";
                        cmd = new SqlCommand(sql, Sqlconn);
                        SqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            Column = Int64.Parse(dr["cID"].ToString());
                        }
                        dr.Close();

                        /*string stuIDName = "";
                        sql = "SELECT Count(*) AS QCOUNT FROM StaffDatabase WHERE Unit=(@Unit) ";
                        cmd = new SqlCommand(sql, Sqlconn);
                        cmd.Parameters.Add("@Unit", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StaffData.unit);
                        string stuNumber = cmd.ExecuteScalar().ToString();*/
                        CaseDataBase SDB = new CaseDataBase();
                        string stuNumber = SDB.getUnitAutoNumber(FieldName);
                        string stuIDName = Chk.CheckStringtoIntFunction(StaffData.unit) + stuNumber.PadLeft(3, '0');

                        sql = "UPDATE StaffDatabase SET StaffID=(@StaffID) WHERE ID=(@TID) ";
                        cmd = new SqlCommand(sql, Sqlconn);
                        cmd.Parameters.Add("@TID", SqlDbType.BigInt).Value = Column;
                        cmd.Parameters.Add("@StaffID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(stuIDName);
                        returnValue[0] = cmd.ExecuteNonQuery().ToString();
                        returnValue[1] = Column.ToString();
                        returnValue[2] = stuIDName;
                    }

                    Sqlconn.Close();
                }
                catch (Exception e)
                {
                    returnValue[0] = "-1";
                    returnValue[1] = e.Message.ToString();
                }

            }
            return returnValue;
    }