private void button1_Click(object sender, EventArgs e) { if (TxtType.Text.Trim().Length <= 0) { MessageBox.Show("Invalid Subscription Type", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (TxtIssues.Text.Trim().Length <= 0) { MessageBox.Show("Invalid No. of Subscriptions", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataSet ds; if (LblPK.Text.Trim().Length > 0) { ds = db.GetTableData("select * from mas_sub_type where sub_type_id<>" + LblPK.Text.Trim() + " and sub_type_name='" + TxtType.Text.Trim() + "'"); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("This Subscription Type already exists", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { ds = db.GetTableData("select * from mas_sub_type where sub_type_name='" + TxtType.Text.Trim() + "'"); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("This Subscription Type already Exists", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } string[] res; if (LblPK.Text.Trim().Length > 0) { res = db.ExecuteQueries("Update mas_sub_type set sub_type_name='" + TxtType.Text.Trim() + "', issues=" + TxtIssues.Text.Trim() + ", Remarks='" + TxtRemarks.Text.Trim() + "', modified_by='" + GlobalClass.UserName + "', modified_date=sysdate where sub_type_id=" + LblPK.Text.Trim()).Split(','); } else { res = db.ExecuteQueries("Insert into mas_sub_type values (" + db.GetNewID("mas_sub_type", "sub_type_id") + ",'" + TxtType.Text.Trim() + "'," + TxtIssues.Text.Trim() + ",'" + TxtRemarks.Text.Trim() + "','" + GlobalClass.UserName + "',sysdate, null, null, 'I')").Split(','); } if (res[0].ToString() != "0") { MessageBox.Show("Insertion / Updation Failure..", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { MessageBox.Show("Successfully Saved", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtIssues.Text = ""; TxtRemarks.Text = ""; TxtType.Text = ""; LblPK.Text = ""; TxtType.Focus(); } }
private void TxtMatricule_SelectedIndexChanged(object sender, EventArgs e) { if (TxtMatricule.Text != "" && TxtConge.Text != "") { E = new Employe(TxtMatricule.Text, FMenu.C); conge = new Conge(E, DateTime.Parse(TxtConge.Text), FMenu.C); if (conge.existance_matricule_date() == false) { BtnAjouter.Enabled = true; BtnSupprimer.Enabled = false; BtnModifier.Enabled = false; TxtType.Text = ""; TxtDuree.Text = ""; } else { BtnAjouter.Enabled = false; BtnSupprimer.Enabled = true; BtnModifier.Enabled = true; conge.recherch_matricule_date(); String date = conge.GetConnextion().dt.Rows[0][1].ToString(); TxtConge.Text = DateTime.Parse(date).ToShortDateString(); TxtType.Text = conge.GetConnextion().dt.Rows[0][2].ToString(); TxtDuree.Text = conge.GetConnextion().dt.Rows[0][3].ToString(); } TxtType.Select(); } }
public L4D2TxtReader(string file, TxtType type) { using (var fs = new FileStream(file, FileMode.Open)) { Run(fs, type); } }
public static void SetEVandME(TxtType type) { string configPath = ""; switch (type) { case TxtType.Passed: configPath = "Passed.ini"; break; case TxtType.Failed: configPath = "Failed.ini"; break; case TxtType.Error: break; case TxtType.Terminated: break; default: break; } #region 读取字段配置文件 try { string line; myEVtxt.Clear(); myMEtxt.Clear(); int which = -1; using (StreamReader sr = new StreamReader(configPath, Encoding.Default)) { while ((line = sr.ReadLine()) != null) { if (line.Contains("--EV--")) { which = 0; continue; } if (line.Contains("--ME--")) { which = 1; continue; } if (which == 1) { myMEtxt.Add(line); } if (which == 0) { myEVtxt.Add(line); } } } } catch (Exception ex) { throw ex; } #endregion SetEVlist(); SetMElist(); }
private void Run(Stream stream, TxtType type) { Values = new List <KeyValuePair <string, string> >(); switch (type) { case TxtType.AddonInfo: LoadAddonInfo(stream); break; case TxtType.AddonList: LoadAddonList(stream); break; } }
public MyTxtFile(string fullname, string name, TxtType type) { fullFileName = fullname; fileName = name; txtType = type; }
/// <summary> /// 将数据导入ME表 /// </summary> /// <param name="connection"></param> /// <param name="count"></param> /// <returns></returns> public bool ImportToMEtable(TxtType type, out int count) { count = 0; try { Constants.SetEVandME(type); } catch (Exception ex) { throw (ex); } using (SqlConnection conn = new SqlConnection(connection)) { conn.Open(); using (SqlTransaction myTrans = conn.BeginTransaction())//建立一个事务 { try { SqlCommand myComm = conn.CreateCommand(); myComm.Transaction = myTrans; String sql = "InsertToME"; //"insert into [ME_MSTR Data] values(@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10,@a11,@a12,@a13,@a14,@a15,@a16,@a17,@a18,@a19,@a20,@a21,@a22,@a23)"; int n = 0; while (n < _content.Count() && _content[n][0].IndexOf("Step_Order") < 0)//以Step_order作为关键字来开始解析测试数据 { n++; } SqlParameter returnPar = new SqlParameter("@return", SqlDbType.Int); returnPar.Direction = ParameterDirection.Output; SqlParameter a1 = new SqlParameter("a1", null); SqlParameter a2 = new SqlParameter("a2", null); SqlParameter a3 = new SqlParameter("a3", null); SqlParameter a4 = new SqlParameter("a4", null); SqlParameter a5 = new SqlParameter("a5", null); SqlParameter a6 = new SqlParameter("a6", null); SqlParameter a7 = new SqlParameter("a7", null); SqlParameter a8 = new SqlParameter("a8", null); SqlParameter a9 = new SqlParameter("a9", null); SqlParameter a10 = new SqlParameter("a10", null); SqlParameter a11 = new SqlParameter("a11", null); SqlParameter a12 = new SqlParameter("a12", null); SqlParameter a13 = new SqlParameter("a13", null); SqlParameter a14 = new SqlParameter("a14", null); SqlParameter a15 = new SqlParameter("a15", null); SqlParameter a16 = new SqlParameter("a16", null); SqlParameter a17 = new SqlParameter("a17", null); SqlParameter a18 = new SqlParameter("a18", null); SqlParameter a19 = new SqlParameter("a19", null); SqlParameter a20 = new SqlParameter("a20", null); SqlParameter a21 = new SqlParameter("a21", null); SqlParameter a22 = new SqlParameter("a22", null); SqlParameter a23 = new SqlParameter("a23", null); SqlParameter[] paras = new SqlParameter[] //作为数据表中的字段匿名 { a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, returnPar }; myComm.CommandType = CommandType.StoredProcedure; myComm.Parameters.AddRange(paras); myComm.CommandText = sql; for (int i = n + 1; i < _content.Count(); ++i)//批量插入数据 { a1.Value = GetContent(i, Constants.MElist[0]); a2.Value = GetContent(i, Constants.MElist[1]); a3.Value = GetContent(i, Constants.MElist[2]); a4.Value = GetContent(i, Constants.MElist[3]); a5.Value = GetContent(i, Constants.MElist[4]); a6.Value = GetContent(i, Constants.MElist[5]); a7.Value = GetContent(i, Constants.MElist[6]); a8.Value = GetContent(i, Constants.MElist[7]); a9.Value = GetContent(i, Constants.MElist[8]); a10.Value = GetContent(i, Constants.MElist[9]); a11.Value = GetContent(i, Constants.MElist[10]); a12.Value = GetContent(i, Constants.MElist[11]); a13.Value = GetContent(i, Constants.MElist[12]); a14.Value = GetContent(i, Constants.MElist[13]); a15.Value = GetContent(i, Constants.MElist[14]); a16.Value = GetContent(i, Constants.MElist[15]); a17.Value = GetContent(i, Constants.MElist[16]); a18.Value = GetContent(i, Constants.MElist[17]); a19.Value = GetContent(i, Constants.MElist[18]); a20.Value = GetContent(i, Constants.MElist[19]); a21.Value = GetContent(i, Constants.MElist[20]); a22.Value = GetContent(i, Constants.MElist[21]); a23.Value = GetContent(i, Constants.MElist[22]); myComm.ExecuteNonQuery(); if ((int)returnPar.Value >= 1) { count++; } } myTrans.Commit();//提交事务 } catch (Exception e) { myTrans.Rollback();//事务回滚 Console.WriteLine("[导入失败]" + e.ToString()); count = 0; throw e; } return(true); } } }
private void txtAssembly_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { txtType = TxtType.Assembly; this.contextMenuStrip2.Show(txtAssembly, e.Location); } }
public L4D2TxtReader(Stream stream, TxtType type) { Run(stream, type); }