private void 添加颜色ToolStripMenuItem_Click(object sender, EventArgs e) { washmange.sql.Color col = new washmange.sql.Color(); AddColor colorForm = new AddColor(); colorForm.ShowDialog(); if (colorForm.cName == "") return; col.colorname = colorForm.cName; col.cRGB = colorForm.cRGB; if (!col.Insert()) { MessageBox.Show("添加失败:" + Mysqlcom.error); return; } Comdata.AllColor = col.GetAll(); listBox3.Items.Add(colorForm.cName); }
/// <summary> /// 线程,链接数据库,并初始化 /// </summary> private static void InitConnect() { string ConStr = string.Format("server={0};port={1};uid={2};pwd={3};database={4};charset={5};Connection Timeout=15;AllowUserVariables=true;Compress=true", ServerSet.FileObj.host, ServerSet.FileObj.port, ServerSet.FileObj.id, ServerSet.FileObj.psw, ServerSet.FileObj.data, ServerSet.FileObj.coding); try { lia.ConnectionString = ConStr; lia.Open(); } catch (Exception ce) { error = "\r\n错误信息:" + ce.Message; Comdata.WriteLog(ConStr + "\r\n" + ce.Message); return; } if (Comdata.AllColor == null) { washmange.sql.Color GetC = new washmange.sql.Color(); washmange.sql.Xiaci GetX = new washmange.sql.Xiaci(); washmange.sql.Brand GetB = new washmange.sql.Brand(); washmange.sql.YangShi GetY = new washmange.sql.YangShi(); //获取所有颜色 Comdata.AllColor = GetC.GetAll(); //瑕疵 Comdata.AllXiaci = GetX.GetAll(); //品牌 Comdata.AllBrand = GetB.GetAll(); //样式 Comdata.AllYs = sql.YangShi.GetAllList(); } #if !ALONE int newVer = Mysqlcom.es("select vVerId from wa_version order by vid desc limit 1"); if (newVer > 0) { if (newVer > Comdata.VersionId) { try { if (!DownFile.DownExe()) return; } catch (Exception ce) { Comdata.WriteLog("DownExe failed!\r\n" + ce.Message); return; } System.Diagnostics.Process.Start(Application.StartupPath + "\\洗衣更新.exe"); Application.Exit(); } } #endif }
private void 删除颜色ToolStripMenuItem_Click(object sender, EventArgs e) { washmange.sql.Color col = new washmange.sql.Color(); if (listBox3.SelectedIndex >= 0) { if (MessageBox.Show("确定要删除 '" + listBox3.SelectedItem + "' ?", "删除颜色", MessageBoxButtons.OKCancel) == DialogResult.OK) { col.CID = (int)Comdata.AllColor.Rows[listBox3.SelectedIndex][0]; if (!col.Delete()) { MessageBox.Show("删除失败!"); return; } Comdata.AllColor.Rows.RemoveAt(listBox3.SelectedIndex); listBox3.Items.RemoveAt(listBox3.SelectedIndex); } } }