Esempio n. 1
0
        public void kichhoatxethue(String maoto)
        {
            OTO oto = db.OTOs.Where(x => x.MAOTO == maoto).First();

            oto.TRANGTHAI = "Đã được thuê";
            db.SubmitChanges();
        }
Esempio n. 2
0
        // xóa ô tô
        public bool xoaoto(String maoto)
        {
            OTO oto = db.OTOs.Where(k => k.MAOTO == maoto).FirstOrDefault();

            db.OTOs.DeleteOnSubmit(oto);
            try
            {
                db.SubmitChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
 public ObjectToObject()
 {
     this.NameSign = @"对象 转 对象";
     this.ExeEvent = () => {
         OTO[] list = new OTO[] {
             //new OTO(null, typeof(int), default(int)),
             //new OTO(null, typeof(OTO), default(OTO)),
             //new OTO(null, typeof(string), null),
             //new OTO(null, typeof(DateTime), default(DateTime)),
             //new OTO(null, typeof(GS.SexEnum), default(GS.SexEnum)),
             new OTO(10, typeof(int), 10),
             new OTO("10", typeof(int), 10),
             new OTO("rrr10", typeof(int), default(int)),
             new OTO(OTO.SexEnum.Male, typeof(int), default(int)),
             new OTO((int)OTO.SexEnum.Male, typeof(OTO.SexEnum), (int)OTO.SexEnum.Male),
             new OTO(((int)OTO.SexEnum.Male).ToString(), typeof(OTO.SexEnum), (int)OTO.SexEnum.Male),
             new OTO(OTO.SexEnum.Male, typeof(OTO.SexEnum), (int)OTO.SexEnum.Male),
             new OTO(10, typeof(float), 10f),
             new OTO("10", typeof(float), 10f),
             new OTO(65, typeof(double), 65.00),
             new OTO("10", typeof(double), 10.0),
             new OTO("50.25", typeof(double), 50.25),
             new OTO("s50.25", typeof(double), default(double)),
             new OTO("s50.25", typeof(string), "s50.25"),
             new OTO("2018-06-01 14:52:22", typeof(DateTime), new DateTime(2018, 06, 01, 14, 52, 22)),
             new OTO(new DateTime(2018, 06, 01, 14, 52, 22), typeof(DateTime), new DateTime(2018, 06, 01, 14, 52, 22)),
         };
         for (int i = 1; i <= list.Length; i++)
         {
             OTO    oto    = list[i - 1];
             object result = ConvertTool.ToObject(oto.Aims_Type, oto.Source);
             if (!oto.Aims_Value.Equals(result))
             {
                 string source_type_fullname     = oto.Source.GetType().FullName;
                 string aims_value_type_fullname = oto.Aims_Value.GetType().FullName;
                 string result_type_fullname     = result.GetType().FullName;
                 Console.WriteLine("i:{0}结果不相等: oto.source:{1}  oto.aims_type:{2}  oto.aims_value:{3}  result:{4}  source_type_fullname:{5}  aims_value_type_fullname:{6}  result_type_fullname:{7}",
                                   i, oto.Source, oto.Aims_Type, oto.Aims_Value, result, source_type_fullname, aims_value_type_fullname, result_type_fullname);
                 return(false);
             }
         }
         return(true);
     };
 }
Esempio n. 4
0
        // sủa ô tô
        public bool suaoto(string maoto, string tenoto, string soghe, string trangthai)
        {
            var kh = new OTO();

            kh = db.OTOs.Where(k => k.MAOTO == maoto).FirstOrDefault();

            kh.TENOTO    = tenoto;
            kh.SOGHE     = soghe;
            kh.TRANGTHAI = trangthai;

            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 5
0
        public void OpenOTO_Click(object sender, EventArgs e)
        {
            openOTO.BackgroundImage = oto2dvcfg.Properties.Resources.buttonAddActive;
            using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
            {
                openFileDialog1.Filter = "UTAU voicebank config file|oto.ini|INI file (*.ini)|*.ini|All files(*.*)|*.*"; //新增開啟檔案視窗

                this.listView1.Items.Clear();
                this.labelOTOint.Text = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK) //若開啟檔案成功
                {
                    if (File.Exists(openFileDialog1.FileName))
                    {
                        formLoading.Show();
                        formLoading.Update();
                        textOTOpath.Text = openFileDialog1.FileName; //取得開啟的檔案路徑
                        string otoPath = textOTOpath.Text;
                        if (otoReader.lineCount(otoPath) - 2 < 0)
                        {
                            MessageBox.Show("oto file is empty.", "(╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            formLoading.Hide();
                        }
                        else
                        {
                            List <string> lines       = new List <string>();
                            List <string> wavNameList = new List <string>();
                            string        line;
                            int           counter        = 0;
                            float         LoadingLine    = 0;
                            float         LoadingPerCent = 0;

                            labelOTOint.Text = Convert.ToString(otoReader.lineCount(otoPath));

                            OTO oto = new OTO();
                            oto.Load(textOTOpath.Text);

                            for (int i = 0; i < oto.lineCount; i++)
                            {
                                ListViewItem[] lvs       = new ListViewItem[1];
                                string         hi2ro     = string.Empty;
                                string         aliasType = otoReader.get_aliasType(oto.otoMap[i].Alias);
                                lvs[0] = new ListViewItem(new string[]
                                {
                                    (i + 1).ToString(),
                                    oto.otoMap[i].File,
                                    oto.otoMap[i].Alias,
                                    oto.otoMap[i].Offset.ToString(),
                                    oto.otoMap[i].Consonant.ToString(),
                                    oto.otoMap[i].Cutoff.ToString(),
                                    oto.otoMap[i].Preutter.ToString(),
                                    oto.otoMap[i].Overlap.ToString(),
                                    aliasType,
                                    otoReader.hi2ro(oto.otoMap[i].Alias),
                                    otoReader.FindAndReplace(oto.otoMap[i].Alias),
                                    otoReader.hi2ron(oto.otoMap[i].Alias, aliasType),
                                    oto.otoMap[i].Alias
                                }
                                                          );
                                listView1.Items.AddRange(lvs);
                            }

                            #region old
                            //StreamReader otoSR = new StreamReader(textOTOpath.Text, System.Text.Encoding.Default); //給ReadLine使用的Reader
                            //while ((line = otoSR.ReadLine()) != null)
                            //{
                            //    string[] otoInputer = OtoInput(line); //輸入一條oto設定進otoSpliter方法
                            //    if (otoInputer.Length < 7)
                            //    {
                            //        MessageBox.Show("Wrong oto format.", "(╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            //        formLoading.Hide();
                            //        return;
                            //    }
                            //    else
                            //    {
                            //        LoadingPerCent = LoadingLine / (otoReader.lineCount(otoPath));
                            //        string hi2ro = string.Empty;
                            //        aliasType = otoReader.get_aliasType(otoInputer[1]);
                            //        ListViewItem[] lvs = new ListViewItem[1];
                            //        lvs[0] = new ListViewItem(new string[]
                            //        {
                            //            Convert.ToString(counter + 1) , //行數
                            //            otoInputer[0], //Wav Name
                            //            otoInputer[1], //Alias
                            //            otoInputer[2], //Offsest
                            //            otoInputer[3], //Consonant
                            //            otoInputer[4], //Cutoff
                            //            otoInputer[5], //Preutterance
                            //            otoInputer[6], //Overlap
                            //            aliasType, //DV需要設定種類
                            //            otoReader.hi2ro(otoInputer[1]),
                            //            otoReader.FindAndReplace(otoInputer[1]),
                            //            otoReader.hi2ron(otoInputer[1], aliasType),
                            //            otoInputer[1]
                            //        }
                            //        );
                            //        listView1.Items.AddRange(lvs);
                            //        counter++;
                            //        LoadingLine++;
                            //        //Console.WriteLine(Math.Round(LoadingPerCent, 3, MidpointRounding.AwayFromZero) * 100 + "%");
                            //        LoadingPerCentSend = Math.Round(LoadingPerCent, 3, MidpointRounding.AwayFromZero);
                            //        FormLoading.PCrefresh();
                            //        formLoading.Refresh();
                            //        formLoading.Update();
                            //    }
                            //}
                            //otoSR.Close();
                            #endregion

                            for (counter = 0; counter < listView1.Items.Count; counter++)
                            {
                                wavNameList.Add(listView1.Items[counter].SubItems[1].Text);
                                wavName = wavNameList.Distinct().ToArray();
                            }

                            #region Does wav file exists?
                            string wavFolder        = string.Empty;
                            string wavPath          = string.Empty;
                            bool   WavDoesnotExists = false;
                            FormWavDoesnotExists formWavDoesnotExists = new FormWavDoesnotExists();
                            if (!string.IsNullOrEmpty(textOTOpath.Text))
                            {
                                wavFolder = textOTOpath.Text.Remove(textOTOpath.Text.LastIndexOf(@"\") + 1); //For detaction
                            }
                            wavPath = wavFolder;
                            foreach (string wavName in wavName)
                            {
                                if (File.Exists(wavFolder + wavName))
                                {
                                }
                                else
                                {
                                    WavDoesnotExists = true;
                                    FormWavDoesnotExists.notExistsList.Add(wavName);
                                }
                            }
                            if (WavDoesnotExists == true)
                            {
                                formWavDoesnotExists.ShowDialog();
                                listView1.Items.Clear();
                                errorMessageInListView();
                            }
                            #endregion
                        }
                        formLoading.Hide();
                    }
                    else
                    {
                        errorMessageInListView();
                    }
                }
                else
                {
                    /*
                     * MessageBox.Show("OTO file not exists.", "(╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                     * formLoading.Hide();
                     * errorMessageInListView();
                     */
                }
            }
        }