Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CheckAll     cka = new CheckAll();
            ReadAndWrite red = new ReadAndWrite();

            string Name      = textBox1.Text;
            string NameMsg   = cka.CheckName(Name);
            string number    = textBox2.Text;
            string NumberMsg = cka.CheckNumber(number);
            string code      = textBox3.Text;
            string CodeMsg   = cka.CheckCode(code);
            string sex       = comboBox1.Text;

            if (NameMsg is "OK" && NumberMsg is "OK" && CodeMsg is "OK")
            {
                NameMsgLab.Text   = "";
                NumberMsgLab.Text = "";
                CodeMsgLab.Text   = "";
                string codeGet = cka.CodeGet(sex, System.Convert.ToInt32(code));
                string OkMsg   = "姓名:  " + Name + "\n學號:  " + number + "\n性別:  " + sex + "\n分數:  " + code + "\n評語:  " + codeGet;
                string Data    = Name + "," + number + "," + sex + "," + code + "," + codeGet;
                int    coun    = treeView1.GetNodeCount(false);
                treeView1.Nodes.Add("姓名:  " + Name);
                treeView1.Nodes[coun].Nodes.Add("學號:  " + number);
                treeView1.Nodes[coun].Nodes.Add("性別:  " + sex);
                treeView1.Nodes[coun].Nodes.Add("分數:  " + code);
                treeView1.Nodes[coun].Nodes.Add("評語:  " + codeGet);
                //string WritwOk = red.Write(Data);

                // MessageBox.Show(WritwOk+""+ OkMsg, "分數已送出");
            }
Beispiel #2
0
        static void Main(string[] args)
        {
            ReadAndWrite ob = new ReadAndWrite();

            ob.msg();
            GetData ob1 = new GetData();

            ob1.msg();
            System.Console.ReadKey();
        }
Beispiel #3
0
        public void EditReadSectionTest()
        {
            string filename = "testFile3";

            ReadAndWrite rw = new ReadAndWrite();

            rw.CreateFileWithTitle(filename, "testSection");
            rw.EditSection(filename, "testSection", "newText");

            Assert.AreEqual("testSection" + "\r\n---\r\n" + "newText", rw.ReadSection(filename, "testSection"));
        }
Beispiel #4
0
        public void CreateFileWithTitleTest()
        {
            string filename = "testFile1";
            string title    = "testTitle";

            ReadAndWrite rw = new ReadAndWrite();

            rw.CreateFileWithTitle(filename, title);

            Assert.IsTrue(File.Exists(filename));
        }
Beispiel #5
0
        //检查该类有没有配置文件,配置文件是否正常
        static CheckYSQL()
        {
            //检查系统配置文件是否存在
            IReadAndWriteYSQL read = new ReadAndWrite();
            //获取当前系统下所有的文件夹
            var current = DirectoryUtil.GetCurrentDirectory();
            var item    = DirectoryUtil.GetDirectoryItems(current);

            //如果该目录下一个文件夹都没有则创建
            if (item.Any())
            {
                //15901492612
                //判断系统文件是否存在
                var paths = DirectoryUtil.GetCurrentDirectory();
                if (!File.Exists(paths + "\\conf\\SystemInfo.conf"))
                {
                    return;
                }
                var jsonStr = read.ReadSys(EnumArray.ReadType.SystemInfo);
                try
                {
                    //检测系统文件是否异常
                    var sysin = new SystemInfo(false);
                    //获取配置文件初始化参数
                    ServiceYSQL.SystemInfoYsql = JsonConvert.DeserializeObject <SystemInfo>(jsonStr);
                    //获取初始化数据库
                    //获取数据库json信息
                    var sysDatabase = read.ReadSys(EnumArray.ReadType.SysDatabase);
                    //序列化对象
                    var sysDatabaseModel = JsonConvert.DeserializeObject <Model.DatabaseInfo>(sysDatabase);
                    ServiceYSQL.SysDatabaseYsql = sysDatabaseModel;
                }
                catch (Exception)
                {
                    throw new Exception();
                    //创建所有系统信息
                    //CreateYSQL.AutoInitSysDatabase();
                    ////系统表初始化
                    //CreateYSQL.AutoDatabase();
                    //CreateYSQL.AutoDatabaseBak();
                }
            }
            else
            {
                //创建所有系统信息
                CreateYSQL.AutoInitSysDatabase();
                //系统表初始化
                CreateYSQL.AutoDatabase();
            }
        }
Beispiel #6
0
        public void DeleteFileTest()
        {
            string filename = "testFile2";

            ReadAndWrite rw = new ReadAndWrite();

            rw.CreateFileWithTitle(filename, "");

            if (File.Exists(filename))
            {
                rw.deleteFile(filename);
                Assert.IsFalse(File.Exists(filename));
            }
            else
            {
                Assert.Fail();
            }
        }
        public IActionResult UploadLVTData(IFormFile file)
        {
            string filename = file?.FileName;
            string FullHTML;

            try
            {
                Validate.ValidateFilename(filename);
                StreamReader jsondata = new StreamReader(file.OpenReadStream());
                string       LVT      = ReadAndWrite.BuildTree(jsondata);
                FullHTML = ReadAndWrite.CreateFullHTML(LVT);
            }
            catch (Exception e)
            {
                return(Ok(e.Message));
            }

            return(Content(FullHTML, "text/html"));
        }
Beispiel #8
0
        public async static Task ExportMarines()
        {
            var marines = new List <Marine>()
            {
                new Marine("Garp", "The Fist", "Vice Admiral[ex]", "Headquartes"),
                new Marine("Sengoku", "Great Buddah", "Fleet Admiral[ex]", "Headquartes"),
                new Marine("Akainu", "Red Dog", "Fleet Admiral", "Headquartes"),
                new Marine("Aokiji", "Blue pheasant", "Admiral[ex]", "Headquarters"),
                new Marine("Smoker", "Chaser", "Vice Admiral", "New World"),
                new Marine("Tashigi", "--Unknown--", "Captain", "New World"),
                new Marine("Coby", "--Unknown--", "--Unknown--", "--Unknown--")
            };

            var excel = new ReadAndWrite <Marine>();

            excel.Content = marines;
            excel.Path    = "marines.xlsx";

            await excel.Export();

            await excel.ReadFromExcel("marines.xlsx");
        }
Beispiel #9
0
        public async static Task ExportPirates()
        {
            var pirates = new List <Pirate>()
            {
                new Pirate("Luffy", "Mugiwara", 500000000, false, "Schichibukai"),
                new Pirate("Zoro", "Kaizoku-Gari", 320000000, false, "Unknown"),
                new Pirate("Ussop", "Sogeking", 177000000, false, "Unknown"),
                new Pirate("Sanji", "Kuroashi", 177000000, false, "Unknown"),
                new Pirate("Nami", "Neko no dorobo", 177000000, false, "Unknown"),
                new Pirate("Chopper", "Kottonkyandiraba", 177000000, false, "Unknown"),
                new Pirate("Robin", "Akuma no ko", 177000000, false, "Unknown"),
                new Pirate("Franky", "Cyborg", 177000000, false, "Unknown"),
                new Pirate("Brook", "Soul King", 177000000, false, "Unknown")
            };

            var excel = new ReadAndWrite <Pirate>();

            excel.Content = pirates;
            excel.Path    = "pirates.xlsx";

            await excel.Export();

            await excel.ReadFromExcel("pirates.xlsx");
        }
Beispiel #10
0
        private void btnSetComplete_Click(object sender, RoutedEventArgs e)
        {
            //设置不能结算的条件
            bool   isSettlement  = false;  //标志是否可以结算
            Double ActualTimes   = 0;      //实际消耗时间
            double dBlance       = 0;      //余额
            int    ActualTries   = 0;      //实际训练次数
            double ActualMileage = 0;      //实际训练里程
            Double ActualBalance = 0;      //实际可结算的余额
            string sTraAmount    = "";     // 训练量

            Double[] dActualTimes   = new Double[2];
            Double[] dActualBalance = new Double[2];
            int[]    sBookSeqNo     = new int[2];
            int      count          = this.dataGridSettlement.SelectedItems.Count;

            TrainingControl.ReadAndWrite readJStoSql = new ReadAndWrite();
            if (this.dataGridSettlement.SelectedItems.Count <= 0)
            {
                System.Windows.Forms.MessageBox.Show("没有选择任何要结算的预约,请重新选择。");
                return;
            }
            else if (count == 1)
            {
                var tempB = (DataRowView)dataGridSettlement.SelectedItems[0];
                dsrsrc.getTraStudinfo(tempB["PID_NO"].ToString());
                if (dsrsrc.trainMangeDataSet.TraineeDataTable.Rows.Count <= 0)
                {
                    return;
                }
                switch (tempB["CHECKSTATUS"].ToString())
                {
                case "未签到":
                    if (System.Windows.Forms.MessageBox.Show("本次预约尚未签到。是否进行结算?", "提示信息:", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        isSettlement = true;
                        dBlance      = Double.Parse(dsrsrc.trainMangeDataSet.TraineeDataTable.Rows[0]["BALANCE"].ToString());
                    }
                    else
                    {
                        return;
                    }
                    break;

                case "已签到":
                    System.Windows.Forms.MessageBox.Show("已经签到,但未读取到训练数据,无法进行结算。");
                    return;

                case "训练中":
                    //检测是否有U盘插入
                    var  s      = DriveInfo.GetDrives();
                    bool isDisk = false;
                    foreach (var drive in s)
                    {
                        if (drive.DriveType == DriveType.Removable)
                        {
                            isDisk = true;
                            var row = dsrsrc.trainMangeDataSet.TraineeDataTable.Rows[0];
                            if (readJStoSql.CompareDisk(drive.Name.ToString(), row["PID_NO"].ToString(), row["DISK_ID"].ToString()))
                            {
                                isSettlement = true;
                            }
                            else
                            {
                                MessageBox.Show("当前插入的U盘不是此学员对应的U盘,请插入正确的U盘");
                                return;
                            }
                        }
                    }
                    if (isDisk == false)
                    {
                        MessageBox.Show("没有检测到移动设备,无法进行结算。");
                        return;
                    }
                    break;

                case "已结束":
                    isSettlement = true;
                    break;

                case "已结算":
                    System.Windows.Forms.MessageBox.Show("本次预约已经结算完成,无法再次结算。");
                    return;
                }
                if (isSettlement == true)
                {
                    dsrsrc.getTraProcessInfo("", "", "", 0, "1900-01-01", "1900-01-01", "", tempB["PID_NO"].ToString(), "", "", "", "", int.Parse(tempB["SEQ_NO"].ToString()));
                    if (dsrsrc.trainMangeDataSet.TraProcessInfoDataTable.Rows.Count > 0)
                    {
                        ActualTimes   = double.Parse(dsrsrc.trainMangeDataSet.TraProcessInfoDataTable.Rows[0]["TRAINING_TIME"].ToString());
                        ActualTries   = int.Parse(dsrsrc.trainMangeDataSet.TraProcessInfoDataTable.Rows[0]["TRAIN_TRIES"].ToString());
                        ActualMileage = double.Parse(dsrsrc.trainMangeDataSet.TraProcessInfoDataTable.Rows[0]["TRAIN_MILEAGE"].ToString());
                    }
                    dActualTimes[0] = ActualTimes;
                    sBookSeqNo[0]   = int.Parse(tempB["SEQ_NO"].ToString());
                    string    sBillMode         = tempB["BILL_MODE"].ToString();
                    double    dChargingStandard = 0;
                    DataRow[] drow = dsrsrc.trainMangeDataSet.BookTrainingDataTable.Select("SEQ_NO = '" + sBookSeqNo[0] + "'");
                    dChargingStandard = dsrsrc.GetChargingStandard(dsrsrc.sBillingMode, dsrsrc.trainMangeDataSet.TraineeDataTable.Rows[0]["LICENSE_TYPE_CD"].ToString());
                    if (dBlance == 0)
                    {
                        dBlance = Double.Parse(dsrsrc.trainMangeDataSet.TraineeDataTable.Rows[0]["UNDER_BALANCE"].ToString());
                    }
                    if (sBillMode == "Time")
                    {
                        dActualBalance[0] = Math.Round(ActualTimes * Math.Round((dChargingStandard / 60), 2), 2);
                        sTraAmount        = ActualTimes.ToString();
                    }
                    else if (sBillMode == "Tries")
                    {
                        dActualBalance[0] = Math.Round(ActualTries * dChargingStandard, 2);
                        sTraAmount        = ActualTries.ToString();
                    }
                    else if (sBillMode == "Mileage")
                    {
                        dActualBalance[0] = Math.Round(ActualMileage * dChargingStandard, 2);
                        sTraAmount        = ActualMileage.ToString();
                    }
                    double dBookBalance = double.Parse(drow[0]["THIS_BALANCE"].ToString());
                    ActualBalance = Math.Round(dBookBalance > dActualBalance[0] ? (dBookBalance - dActualBalance[0]) : 0);
                    UpdateBoxWindow ubw = new UpdateBoxWindow(tempB["PID_NO"].ToString(), tempB["TRAINE_NAME"].ToString(), ActualBalance, sTraAmount, dActualBalance, sBookSeqNo, sBillMode, dBlance);
                    ubw.ShowDialog();
                }
            }
        }