Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();

            DataTable dt = (DataTable)dataGridView1.DataSource;
            Dictionary <string, HeiFeiMideaDll.cBoShi.BoShiValue> buff = new Dictionary <string, HeiFeiMideaDll.cBoShi.BoShiValue>();
            string midea = "";

            HeiFeiMideaDll.cBoShi.BoShiValue boshi = new HeiFeiMideaDll.cBoShi.BoShiValue("", "");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                midea = All.Class.Num.ToString(dt.Rows[i]["Midea"]);
                boshi = new HeiFeiMideaDll.cBoShi.BoShiValue(
                    All.Class.Num.ToString(dt.Rows[i]["Boshi"]),
                    All.Class.Num.ToString(dt.Rows[i]["BoShiJiXing"]));
                if (!buff.ContainsKey(midea))
                {
                    buff.Add(midea, boshi);
                }
            }
            if (HeiFeiMideaDll.cBoShi.SaveAllMode(buff, frmMain.mMain.AllDataBase.LocalData))
            {
                All.Window.MetroMessageBox.Show(this, "所有机型已成功保存到数据库", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                All.Window.MetroMessageBox.Show(this, "机型数据保存失败,请检查后再重新尝试", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加一组对应关系
 /// </summary>
 /// <param name="midea"></param>
 /// <param name="boShi"></param>
 private void AddMode(string midea, HeiFeiMideaDll.cBoShi.BoShiValue boShi)
 {
     if (AllMode.Keys.ToList().FindIndex(
             str =>
     {
         return(str == midea);
     }) >= 0)
     {
         return;
     }
     AllMode.Add(midea, boShi);
     Save();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 从文本文件中加载美的与博世的对应关系
 /// </summary>
 public void Load()
 {
     if (System.IO.File.Exists(fileName))
     {
         HeiFeiMideaDll.cBoShi.BoShiValue tmpBoShi;
         string[] tmpValue;
         Dictionary <string, string> buff = All.Class.SSFile.Text2Dictionary(All.Class.FileIO.ReadFile(fileName));
         buff.Keys.ToList().ForEach(
             tmpBuff =>
         {
             tmpValue = buff[tmpBuff].Split('|');
             if (tmpValue.Length == 2)
             {
                 tmpBoShi = new HeiFeiMideaDll.cBoShi.BoShiValue(tmpValue[0], tmpValue[1]);
                 if (!AllMode.ContainsKey(tmpBuff))
                 {
                     AllMode.Add(tmpBuff, tmpBoShi);
                 }
             }
         });
     }
 }