public void RowInAccessibleTest() { Assert.Throws<InvalidOperationException>(() => { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); reader.Read(); // 2nd row _dt.Rows[1].Delete(); string value = reader[1].ToString(); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
public void CtorTest() { _dt.Rows[1].Delete(); DataTableReader reader = new DataTableReader(_dt); try { int i = 0; while (reader.Read()) i++; reader.Close(); Assert.Equal(2, i); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public override bool ProcessImportData(DataRow row, List <string> sys, List <string> src, string DepartUpID, ref string ErrorMsg) { bool ret = base.ProcessImportData(row, sys, src, DepartUpID, ref ErrorMsg); string EmpNo = ""; string EmpName = ""; string EmpSex = ""; string DepartID = ""; string DepartName = ""; string EmpHireDate = ""; string EmpCertNo = ""; string CardNo10 = ""; string CardNo81 = ""; string CardNo82 = ""; string EmpPWDNo = ""; string FingerNo = ""; string FingerPrivilege = ""; string IsAttend = ""; string EmpGZ = ""; string RuleID = ""; string EmpAddress = ""; string EmpPhoneNo = ""; string EmpMemo = ""; string StartDate = ""; string EndDate = ""; for (int i = 0; i < sys.Count; i++) { switch (sys[i]) { case "EmpNo": EmpNo = row[src[i]].ToString(); break; case "EmpName": EmpName = row[src[i]].ToString(); break; case "EmpSex": EmpSex = row[src[i]].ToString(); break; case "DepartID": DepartID = row[src[i]].ToString(); break; case "DepartName": DepartName = row[src[i]].ToString(); break; case "EmpHireDate": EmpHireDate = row[src[i]].ToString(); break; case "EmpCertNo": EmpCertNo = row[src[i]].ToString(); break; case "FingerNo": FingerNo = row[src[i]].ToString(); break; case "FingerPrivilege": FingerPrivilege = row[src[i]].ToString(); break; case "IsAttend": IsAttend = row[src[i]].ToString(); break; case "EmpGZ": EmpGZ = row[src[i]].ToString(); break; case "RuleID": RuleID = row[src[i]].ToString(); break; case "EmpAddress": EmpAddress = row[src[i]].ToString(); break; case "EmpPhoneNo": EmpPhoneNo = row[src[i]].ToString(); break; case "EmpCardNo": CardNo10 = row[src[i]].ToString(); break; case "EmpPWDNo": EmpPWDNo = row[src[i]].ToString(); break; case "EmpMemo": EmpMemo = row[src[i]].ToString(); break; case "StartDate": StartDate = row[src[i]].ToString(); break; case "EndDate": EndDate = row[src[i]].ToString(); break; } } if (EmpNo == "") { ErrorMsg = Pub.GetResText(formCode, "Error101", ""); return(false); } if ((DepartID == "") && (DepartName == "")) { DepartID = SystemInfo.CommanyID; } if (EmpSex != SystemInfo.EmpSexMale && EmpSex != SystemInfo.EmpSexFemale) { EmpSex = ""; } if (IsAttend != "0") { IsAttend = "1"; } if (FingerPrivilege != "0" && FingerPrivilege != "1") { if (FingerPrivilege != SystemInfo.FingerPrivilegeManager) { FingerPrivilege = SystemInfo.FingerPrivilegeGeneralUser; } } if (FingerPrivilege == SystemInfo.FingerPrivilegeManager) { FingerPrivilege = "1"; } else { FingerPrivilege = "0"; } if (IsAttend != "0") { IsAttend = "1"; } if (!Pub.IsNumeric(EmpGZ)) { EmpGZ = "0.00"; } StartDate = stringToTimeStr(StartDate); EndDate = stringToTimeStr(EndDate); StartDate = CheckTimeStr(StartDate); EndDate = CheckTimeStr(EndDate); if (SystemInfo.DBType == 0) { if (StartDate == null) { StartDate = "NULL"; } else { StartDate = "CDate('" + StartDate + "')"; } if (EndDate == null) { EndDate = "NULL"; } else { EndDate = "CDate('" + EndDate + "')"; } } else { if (StartDate == null) { StartDate = "NULL"; } else { StartDate = "'" + StartDate + "'"; } if (EndDate == null) { EndDate = "NULL"; } else { EndDate = "'" + EndDate + "'"; } } bool IsError = false; DataTableReader dr = null; string sql = ""; try { if (DepartID == "") { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000101, new string[] { "3", DepartName })); if (dr.Read()) { DepartID = dr["DepartID"].ToString(); } else { dr.Close(); dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000101, new string[] { "4" })); string s = ""; if (dr.Read()) { s = dr[0].ToString(); } dr.Close(); if (Pub.IsNumeric(s)) { if (s == "0001") { s = "00010001"; } else { DepartImportID = Convert.ToInt32(s) + 1; s = DepartImportID.ToString("00000000"); } } else { s = DepartImportID.ToString("00000000"); } dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000100, new string[] { "1", s })); while (dr.Read()) { dr.Close(); DepartImportID = DepartImportID + 1; s = DepartImportID.ToString("000000"); dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000100, new string[] { "1", s })); } DepartID = s; sql = Pub.GetSQL(DBCode.DB_000100, new string[] { "4", DepartID, DepartName, DepartUpID, "" }); SystemInfo.db.ExecSQL(sql); } dr.Close(); } else if (DepartID != SystemInfo.CommanyID) { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000100, new string[] { "1", DepartID })); bool HasDepart = false; if (dr.Read()) { HasDepart = true; } dr.Close(); if (!HasDepart) { if (DepartName != "") { sql = Pub.GetSQL(DBCode.DB_000100, new string[] { "4", DepartID, DepartName, DepartUpID, "" }); SystemInfo.db.ExecSQL(sql); } else { ErrorMsg = Pub.GetResText(formCode, "Error103", ""); return(false); } } } if (DepartID == "") { ErrorMsg = Pub.GetResText(formCode, "Error103", ""); return(false); } DateTime d = new DateTime(); if (DateTime.TryParse(EmpHireDate, out d)) { if (SystemInfo.DBType == 0) { EmpHireDate = "CDate('" + d.ToString(SystemInfo.SQLDateFMT) + "')"; } else { EmpHireDate = "'" + d.ToString(SystemInfo.SQLDateFMT) + "'"; } } else { EmpHireDate = Pub.GetSQL(DBCode.DB_000001, new string[] { "13" }); } if (CardNo10 != "") { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000101, new string[] { "14", CardNo10 })); if (dr.Read()) { CardNo10 = ""; } dr.Close(); } if (FingerNo == "" || !Pub.IsNumeric(FingerNo)) { FingerNo = ""; } if (FingerNo != "") { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000101, new string[] { "10", FingerNo })); if (dr.Read()) { FingerNo = ""; } } if (FingerNo == "" || !Pub.IsNumeric(FingerNo)) { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000101, new string[] { "11" })); dr.Read(); FingerNo = dr[0].ToString(); } dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000101, new string[] { "5", EmpNo })); if (!dr.Read()) { dr.Close(); sql = Pub.GetSQL(DBCode.DB_000101, new string[] { "6", EmpNo, EmpName, EmpSex, DepartID, EmpHireDate, EmpCertNo, CardNo10, CardNo81, CardNo82, FingerNo, FingerPrivilege, IsAttend, RuleID, EmpAddress, EmpPhoneNo, EmpMemo, EmpGZ, EmpPWDNo, StartDate, EndDate }); SystemInfo.db.ExecSQL(sql); string picPath = SystemInfo.AppPath + "EmpPic\\"; string picFileName = picPath + EmpNo + ".jpg"; if (!File.Exists(picFileName)) { picFileName = picPath + EmpNo + ".bmp"; } if (!File.Exists(picFileName)) { picFileName = picPath + EmpNo + ".png"; } if (!File.Exists(picFileName)) { picFileName = picPath + EmpName + ".jpg"; } if (!File.Exists(picFileName)) { picFileName = picPath + EmpName + ".bmp"; } if (!File.Exists(picFileName)) { picFileName = picPath + EmpName + ".png"; } if (File.Exists(picFileName)) { string fileName = Pub.GetTempPathFileName(picFileName); CustomSizeImageFile(picFileName, fileName); byte[] buff = new byte[0]; MemoryStream ms = new MemoryStream(); using (Bitmap t = new Bitmap(fileName)) { t.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); t.Dispose(); buff = ms.ToArray(); } SystemInfo.db.UpdateByteData(Pub.GetSQL(DBCode.DB_000101, new string[] { "7", EmpNo }), "EmpPhotoImage", buff); fileName = Pub.GetTempPathFileName(picFileName); CustomSizePhotoFile(picFileName, fileName); buff = new byte[0]; ms = new MemoryStream(); using (Bitmap ti = new Bitmap(fileName)) { ti.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); ti.Dispose(); buff = ms.ToArray(); } SystemInfo.db.UpdateByteData(Pub.GetSQL(DBCode.DB_000101, new string[] { "24", EmpNo }), "EmpPhoto", buff); if (buff.Length > 0) { SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000101, new string[] { "35", EmpNo, "1" })); } } } else { ErrorMsg = Pub.GetResText(formCode, "Error104", ""); return(false); } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E, sql); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return(false); } SystemInfo.db.WriteSYLog(this.Text, CurrentTool, sql); return(ret); }
private void LoadData() { DataTableReader dr = null; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (SysID == "") { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "2002" })); if (dr.Read()) { int no = 0; int.TryParse(dr[0].ToString(), out no); if (no > SystemInfo.MaxSNFinger) { no = SystemInfo.MaxSNFinger; } txtMacSN.Text = no.ToString(); } } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "2003", SysID })); if (dr.Read()) { txtMacSN.Text = dr["MacSN"].ToString(); switch (dr["MacConnType"].ToString()) { case MacConnTypeString.USB: rbUSB.Checked = true; break; case MacConnTypeString.Comm: rbComm.Checked = true; cbbCommPort.Text = dr["MacPort"].ToString(); cbbCommBaudRate.Text = dr["MacConnPWD"].ToString(); break; case MacConnTypeString.LAN: rbLAN.Checked = true; txtLANIP.Text = dr["MacIpAddress"].ToString(); txtLANPort.Text = dr["MacPort"].ToString(); chkGPRS.Checked = Pub.ValueToBool(dr["IsGPRS"]); break; } txtDesc.Text = dr["MacDesc"].ToString(); } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } }
protected override void InitForm() { Pub.SetFormAppIcon(this); System.Globalization.DateTimeFormatInfo fmtInfo = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat; LocalFormat = "dddd " + fmtInfo.LongDatePattern + " " + fmtInfo.LongTimePattern; Rectangle rect = Screen.PrimaryScreen.WorkingArea; formCode = "Main"; base.InitForm(); MDICaption = SystemInfo.AppTitle + " " + SystemInfo.AppVersion; if (SystemInfo.CustomerName != "") { MDICaption = MDICaption + "[" + SystemInfo.CustomerName + "]"; } this.Left = rect.Left; this.Top = rect.Top; this.Width = rect.Width; this.Height = rect.Height; this.WindowState = FormWindowState.Maximized; this.Text = SystemInfo.AppTitle; SystemInfo.SystemIsExit = false; SystemInfo.MainHandle = this.Handle; lblUser.Text = lblUser.Text + OprtInfo.OprtNoAndName; lblAcc.Text = lblAcc.Text + SystemInfo.AccDBName; if (SystemInfo.AccDBName != SystemInfo.DatabaseName) { lblAcc.Text = lblAcc.Text + "[" + SystemInfo.DatabaseName + "]"; } SystemInfo.funcList.Clear(); int itemIndex = 1; LoadDll(ref objRS, ref tpRS, "ECard78.RS.dll", ref itemIndex, mnuRS_Click); LoadDll(ref objKQ, ref tpKQ, "ECard78.KQ.dll", ref itemIndex, mnuKQ_Click); LoadDll(ref objMJ, ref tpMJ, "ECard78.MJNew.dll", ref itemIndex, mnuMJ_Click); if (objMJ == null || tpMJ == null) { LoadDll(ref objMJ, ref tpMJ, "ECard78.MJ.dll", ref itemIndex, mnuMJ_Click); } SystemInfo.IsNewMJ = MJIsNew(objMJ, tpMJ); LoadDll(ref objSF, ref tpSF, "ECard78.SF.dll", ref itemIndex, mnuSF_Click); LoadDll(ref objSK, ref tpSK, "ECard78.SK.dll", ref itemIndex, mnuSK_Click); LoadDll(ref objSEA, ref tpSEA, "ECard78.SEA.dll", ref itemIndex, mnuSEA_Click); SystemInfo.HasRS = (objRS != null) && (tpRS != null); SystemInfo.HasKQ = (objKQ != null) && (tpKQ != null); SystemInfo.HasMJ = (objMJ != null) && (tpMJ != null); SystemInfo.HasSF = (objSF != null) && (tpSF != null); SystemInfo.HasSK = (objSK != null) && (tpSK != null); SystemInfo.HasSEA = (objSEA != null) && (tpSEA != null); SystemInfo.KQFlag = KQFlag(objKQ, tpKQ); if (SystemInfo.HasRS) { LoadDll(ref objRSReport, ref tpRSReport, "RSReport.dll", ref itemIndex, mnuRSReport_Click, false); } if (SystemInfo.HasKQ) { LoadDll(ref objKQReport, ref tpKQReport, "KQReport.dll", ref itemIndex, mnuKQReport_Click, false); } if (SystemInfo.HasMJ) { LoadDll(ref objMJReport, ref tpMJReport, "MJReport.dll", ref itemIndex, mnuMJReport_Click, false); } if (SystemInfo.HasSF) { LoadDll(ref objSFReport, ref tpSFReport, "SFReport.dll", ref itemIndex, mnuSFReport_Click, false); } if (SystemInfo.HasSK) { LoadDll(ref objSKReport, ref tpSKReport, "SKReport.dll", ref itemIndex, mnuSKReport_Click, false); } if (SystemInfo.HasSEA) { LoadDll(ref objSEAReport, ref tpSEAReport, "SEAReport.dll", ref itemIndex, mnuSEAReport_Click, false); } SystemInfo.HasFaCard = false; if ((SystemInfo.HasKQ && ((SystemInfo.KQFlag == 0) || (SystemInfo.KQFlag == 2))) || SystemInfo.HasSF || SystemInfo.HasSK) { SystemInfo.HasFaCard = true; } ToolBar.Items.Clear(); AddToolbarButton(mnuWindowClose.Text, mnuWindowClose.Image, mnuWindowClose_Click); AddToolbarSeparator(); AddToolbarButton(mnuSYClose.Text, mnuSYClose.Image, mnuSYClose_Click); string dllName = ""; System.Collections.ArrayList objList = new System.Collections.ArrayList(); System.Collections.ArrayList tpList = new System.Collections.ArrayList(); System.Collections.ArrayList naList = new System.Collections.ArrayList(); Assembly obj; Type tp; string na; for (int i = 1; i <= 10; i++) { dllName = SystemInfo.ini.ReadIni("ExtDll", i.ToString(), ""); if (dllName == "") { continue; } if (!File.Exists(SystemInfo.AppPath + dllName)) { continue; } obj = null; tp = null; LoadDll(ref obj, ref tp, dllName, ref itemIndex, mnuExt_Click); na = GetDllName(obj, tp); objList.Add(obj); tpList.Add(tp); naList.Add(na); } ExtModuleInfo.objDll = new Assembly[objList.Count]; ExtModuleInfo.tpDll = new Type[objList.Count]; ExtModuleInfo.homeName = new string[objList.Count]; for (int i = 0; i < objList.Count; i++) { ExtModuleInfo.objDll[i] = (Assembly)objList[i]; ExtModuleInfo.tpDll[i] = (Type)tpList[i]; ExtModuleInfo.homeName[i] = (string)naList[i]; } ShowMDIForm(new frmMainHome()); db.SetConnStr(SystemInfo.ConnStr); RegisterInfo.Serial = db.GetRegSerial(); RegisterInfo.EmpCount = db.GetEmpCount(); RegisterInfo.ModuleCount = 0; if (SystemInfo.HasKQ) { RegisterInfo.ModuleCount += 1; } if (SystemInfo.HasMJ) { RegisterInfo.ModuleCount += 1; } if (SystemInfo.HasSF) { RegisterInfo.ModuleCount += 1; } if (SystemInfo.HasSK) { RegisterInfo.ModuleCount += 1; } if (SystemInfo.HasSEA) { RegisterInfo.ModuleCount += 1; } if (ExtModuleInfo.objDll != null) { RegisterInfo.ModuleCount += ExtModuleInfo.objDll.Length; } RegisterInfo.MustReg = db.ReadConfig("SystemRegister", "MustReg", false); if (SystemInfo.DBType == 1) { Database dbSerial = new Database(GetConnStrSystem()); try { if (!dbSerial.IsOpen) { dbSerial.Open(); } string tmpSerial = dbSerial.GetDBServerSerial(); if (tmpSerial != "") { RegisterInfo.Serial = tmpSerial; } } finally { dbSerial.Close(); } } RegisterInfo.AllowReg = (RegisterInfo.EmpCount >= 300) || (RegisterInfo.ModuleCount > 1) || RegisterInfo.MustReg; if (SystemInfo.IgnoreRegister) { RegisterInfo.AllowReg = false; } if (RegisterInfo.AllowReg) { db.IsRegister(true, "", ""); } SetMDICaption(); if (SystemInfo.HasRS) { db.UpdateModuleResources(this.Text, objRS); } if (SystemInfo.HasKQ) { db.UpdateModuleResources(this.Text, objKQ); } if (SystemInfo.HasMJ) { db.UpdateModuleResources(this.Text, objMJ); } if (SystemInfo.HasSF) { db.UpdateModuleResources(this.Text, objSF); } if (SystemInfo.HasSK) { db.UpdateModuleResources(this.Text, objSK); } if (SystemInfo.HasSEA) { db.UpdateModuleResources(this.Text, objSEA); } if (objRSReport != null) { db.UpdateModuleResources(this.Text, objRSReport); } if (objKQReport != null) { db.UpdateModuleResources(this.Text, objKQReport); } if (objMJReport != null) { db.UpdateModuleResources(this.Text, objMJReport); } if (objSFReport != null) { db.UpdateModuleResources(this.Text, objSFReport); } if (objSKReport != null) { db.UpdateModuleResources(this.Text, objSKReport); } if (objSEAReport != null) { db.UpdateModuleResources(this.Text, objSEAReport); } DataTableReader dr = null; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_000002, new string[] { "2" })); if (dr.Read()) { SystemInfo.AccDBVersion = dr["DbVersion"].ToString() + "."; DateTime dt = Convert.ToDateTime(dr["DbDate"]); SystemInfo.AccDBVersion = SystemInfo.AccDBVersion + dt.ToString("yyyy.MM.dd"); } } finally { if (dr != null) { dr.Close(); } dr = null; } }
public void DeleteLastAndAcceptChangesTest2() { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row reader.Read(); // second row reader.Read(); // third row _dt.Rows[2].Delete(); // delete row, where reader points to _dt.AcceptChanges(); // accept the action Assert.Equal(2, (int)reader[0]); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public void DontSeeTheEarlierRowsTest() { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row reader.Read(); // second row // insert a row at position 0 DataRow r = _dt.NewRow(); r[0] = 0; r[1] = "adhi bagavan"; _dt.Rows.InsertAt(r, 0); Assert.Equal(2, reader.GetInt32(0)); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public void NoTablesTest() { Assert.Throws<ArgumentException>(() => { DataTableReader reader = new DataTableReader(new DataTable[] { }); try { reader.Read(); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
public Atualizacao Sincronizar(List <string> atualizacoes, DateTime ultimaSincronizacao, string identificacao) { BancoDeDados bd = new BancoDeDados(); try { if (bd.BeginTransaction()) { foreach (string sql in atualizacoes) { NpgsqlCommand comando = new NpgsqlCommand(sql); bd.NonQuery(comando); } Atualizacao atualizacao = new Atualizacao(); bool buscarIds = false; #region Identificacao NpgsqlCommand command = new NpgsqlCommand("SELECT id FROM celular WHERE identificacao = '" + identificacao + "'"); DataSet ds = bd.Query(command); if (ds == null) { return(null); } DataTableReader dtr = ds.CreateDataReader(); if (dtr.Read()) { atualizacao.idCelular = dtr.GetInt32(0); if (ultimaSincronizacao.Ticks == 0) { buscarIds = true; } } else { command = new NpgsqlCommand("INSERT INTO celular(identificacao) VALUES ('" + identificacao + "')"); bd.NonQuery(command); command = new NpgsqlCommand("SELECT id FROM celular WHERE identificacao = '" + identificacao + "'"); ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); dtr.Read(); atualizacao.idCelular = dtr.GetInt32(0); } #endregion #region Cliente command = new NpgsqlCommand(@"SELECT id, nome, cpf, rua, numero, bairro, cidade, uf, cep, complemento, telefone, email, ativo, alteracao FROM cliente WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <ClienteWS> clientes = new List <ClienteWS>(); while (dtr.Read()) { clientes.Add(new ClienteWS() { Id = dtr.GetString(0), Nome = dtr.GetString(1), Cpf = dtr.GetString(2), Rua = dtr.GetString(3), Numero = dtr.GetString(4), Bairro = dtr.GetString(5), Cidade = dtr.GetString(6), Uf = dtr.GetString(7), Cep = (dtr.IsDBNull(8) || string.IsNullOrWhiteSpace(dtr.GetString(8))) ? null : dtr.GetString(8), Complemento = (dtr.IsDBNull(9) || string.IsNullOrWhiteSpace(dtr.GetString(9))) ? null : dtr.GetString(9), Telefone = (dtr.IsDBNull(10) || string.IsNullOrWhiteSpace(dtr.GetString(10))) ? null : dtr.GetString(10), Email = (dtr.IsDBNull(11) || string.IsNullOrWhiteSpace(dtr.GetString(11))) ? null : dtr.GetString(11), Ativo = dtr.GetBoolean(12) }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(13)) { atualizacao.dtAtualizado = dtr.GetDateTime(13); } if (buscarIds) { string[] aux = dtr.GetString(0).Split('/'); int id = Convert.ToInt32(aux[1]); if (atualizacao.idCelular == Convert.ToInt32(aux[0]) && (atualizacao.maxIdCliente == null || atualizacao.maxIdCliente < id)) { atualizacao.maxIdCliente = id; } } } atualizacao.clientes = clientes; #endregion #region Produto command = new NpgsqlCommand(@"SELECT id, nome, estoque, valor, ativo, alteracao FROM produto WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <ProdutoWS> produtos = new List <ProdutoWS>(); while (dtr.Read()) { produtos.Add(new ProdutoWS() { Id = dtr.GetInt32(0), Nome = dtr.GetString(1), Estoque = dtr.GetDecimal(2), Valor = dtr.GetDecimal(3), Ativo = dtr.GetBoolean(4) }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(5)) { atualizacao.dtAtualizado = dtr.GetDateTime(5); } } atualizacao.produtos = produtos; #endregion #region Pedido command = new NpgsqlCommand(@"SELECT id, id_cliente, id_vendedor, valor, data_emissao, data_pagamento, observacoes, alteracao FROM pedido WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <PedidoWS> pedidos = new List <PedidoWS>(); while (dtr.Read()) { pedidos.Add(new PedidoWS() { Id = dtr.GetString(0), IdCliente = dtr.GetString(1), IdVendedor = dtr.GetInt32(2), Valor = dtr.GetDecimal(3), DataEmissao = dtr.GetDateTime(4), DataPagamento = dtr.GetDateTime(5), Observacoes = dtr.GetString(6) }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(7)) { atualizacao.dtAtualizado = dtr.GetDateTime(7); } if (buscarIds) { string[] aux = dtr.GetString(0).Split('/'); int id = Convert.ToInt32(aux[1]); if (atualizacao.idCelular == Convert.ToInt32(aux[0]) && (atualizacao.maxIdPedido == null || atualizacao.maxIdPedido < id)) { atualizacao.maxIdPedido = id; } } } atualizacao.pedidos = pedidos; #endregion #region Produtos Pedido command = new NpgsqlCommand(@"SELECT id, id_pedido, id_produto, valor, quantidade, quantidade_entregue, alteracao FROM produto_pedido WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <ProdutoPedidoWS> produtospedido = new List <ProdutoPedidoWS>(); while (dtr.Read()) { produtospedido.Add(new ProdutoPedidoWS() { Id = dtr.GetString(0), IdPedido = dtr.GetString(1), IdProduto = dtr.GetInt32(2), Valor = dtr.GetDecimal(3), Quantidade = dtr.GetDecimal(4), QuantidadeEntregue = dtr.GetDecimal(5) }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(6)) { atualizacao.dtAtualizado = dtr.GetDateTime(6); } if (buscarIds) { string[] aux = dtr.GetString(0).Split('/'); int id = Convert.ToInt32(aux[1]); if (atualizacao.idCelular == Convert.ToInt32(aux[0]) && (atualizacao.maxIdProdutoPedido == null || atualizacao.maxIdProdutoPedido < id)) { atualizacao.maxIdProdutoPedido = id; } } } atualizacao.produtospedido = produtospedido; #endregion #region Receber command = new NpgsqlCommand(@"SELECT id, id_pedido, ordem, valor, vencimento, pagamento, alteracao FROM receber WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <ReceberWS> receber = new List <ReceberWS>(); while (dtr.Read()) { receber.Add(new ReceberWS() { Id = dtr.GetString(0), IdPedido = dtr.GetString(1), Ordem = dtr.GetInt32(2), Valor = dtr.GetDecimal(3), Vencimento = dtr.GetDateTime(4), Pagamento = dtr.GetDateTime(5), }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(6)) { atualizacao.dtAtualizado = dtr.GetDateTime(6); } if (buscarIds) { string[] aux = dtr.GetString(0).Split('/'); int id = Convert.ToInt32(aux[1]); if (atualizacao.idCelular == Convert.ToInt32(aux[0]) && (atualizacao.maxIdReceber == null || atualizacao.maxIdReceber < id)) { atualizacao.maxIdReceber = id; } } } atualizacao.receber = receber; #endregion #region Anotacao command = new NpgsqlCommand(@"SELECT id, id_pedido, data, data_ultima_alteracao, texto, alteracao FROM anotacao WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <AnotacaoWS> anotacoes = new List <AnotacaoWS>(); while (dtr.Read()) { anotacoes.Add(new AnotacaoWS() { Id = dtr.GetString(0), IdPedido = dtr.GetString(1), Data = dtr.GetDateTime(2), DataUltimaAlteracao = dtr.GetDateTime(3), Texto = dtr.GetString(4) }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(5)) { atualizacao.dtAtualizado = dtr.GetDateTime(5); } if (buscarIds) { string[] aux = dtr.GetString(0).Split('/'); int id = Convert.ToInt32(aux[1]); if (atualizacao.idCelular == Convert.ToInt32(aux[0]) && (atualizacao.maxIdAnotacao == null || atualizacao.maxIdAnotacao < id)) { atualizacao.maxIdAnotacao = id; } } } atualizacao.anotacoes = anotacoes; #endregion #region Vendedor command = new NpgsqlCommand(@"SELECT id, nome, alteracao FROM vendedor WHERE alteracao > @alt ORDER BY Id"); command.Parameters.Add("alt", NpgsqlDbType.Timestamp).Value = ultimaSincronizacao; ds = bd.Query(command); if (ds == null) { return(null); } dtr = ds.CreateDataReader(); List <VendedorWS> vendedores = new List <VendedorWS>(); while (dtr.Read()) { vendedores.Add(new VendedorWS() { Id = dtr.GetInt32(0), Nome = dtr.GetString(1) }); if (atualizacao.dtAtualizado == null || atualizacao.dtAtualizado < dtr.GetDateTime(2)) { atualizacao.dtAtualizado = dtr.GetDateTime(2); } } atualizacao.vendedores = vendedores; #endregion if (bd.CommitTransaction()) { return(atualizacao); } else { bd.RollbackTransaction(); } } }catch (Exception) { bd.RollbackTransaction(); } return(null); }
protected override void ExecItemTAG1() { bool IsError = false; DataTableReader dr = null; AccessV2API.TYPE_DoorExpertTiming Timing; try { if (DownFlag == 0) { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003009, new string[] { "100" })); int index = 0; string s = ""; while (dr.Read()) { Timing = new AccessV2API.TYPE_DoorExpertTiming(); Timing.DayOfWeek = (UInt32)index; Timing.TimeBegin = new AccessV2API.SYSTEMTIME[4]; Timing.TimeEnd = new AccessV2API.SYSTEMTIME[4]; Timing.DoorMode = new UInt32[4]; for (int i = 1; i <= 4; i++) { s = dr["BeginTime" + i.ToString()].ToString(); if (s.Length == 5) { Timing.TimeBegin[i - 1].wHour = Convert.ToUInt16(s.Substring(0, 2)); Timing.TimeBegin[i - 1].wMinute = Convert.ToUInt16(s.Substring(3, 2)); } s = dr["EndTime" + i.ToString()].ToString(); if (s.Length == 5) { Timing.TimeEnd[i - 1].wHour = Convert.ToUInt16(s.Substring(0, 2)); Timing.TimeEnd[i - 1].wMinute = Convert.ToUInt16(s.Substring(3, 2)); } UInt32.TryParse(dr["Mode" + i.ToString()].ToString(), out Timing.DoorMode[i - 1]); } ExpertTiming[index] = Timing; index++; } } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return; } base.ExecItemTAG1(); ExecMacDoorOprt(0); }
public override bool ProcessImportData(DataRow row, List <string> sys, List <string> src, string DepartUpSysID, ref string ErrorMsg, ref double Sum) { bool ret = base.ProcessImportData(row, sys, src, DepartUpSysID, ref ErrorMsg, ref Sum); int CategoryID = 0; string CategoryName = ""; int ProductsID = 0; string ProductsName = ""; double ProductsPrice = 0; for (int i = 0; i < sys.Count; i++) { switch (sys[i]) { case "CategoryID": CategoryID = 0; int.TryParse(row[src[i]].ToString(), out CategoryID); break; case "CategoryName": CategoryName = row[src[i]].ToString().Trim(); break; case "ProductsID": ProductsID = 0; int.TryParse(row[src[i]].ToString(), out ProductsID); break; case "ProductsName": ProductsName = row[src[i]].ToString().Trim(); break; case "ProductsPrice": ProductsPrice = 0; double.TryParse(CurrencyToStringEx(row[src[i]].ToString()), out ProductsPrice); break; } } if ((ProductsID < 1) || (ProductsID > 9999)) { ErrorMsg = Pub.GetResText(formCode, "Error001", ""); return(false); } if (ProductsName == "") { ErrorMsg = Pub.GetResText(formCode, "Error002", ""); return(false); } if (ProductsPrice <= 0) { ErrorMsg = Pub.GetResText(formCode, "Error003", ""); return(false); } bool IsError = false; DataTableReader dr = null; string sql = ""; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004003, new string[] { "5", ProductsID.ToString(), CategoryID.ToString() })); if (!dr.Read()) { dr.Close(); sql = Pub.GetSQL(DBCode.DB_004003, new string[] { "1", ProductsID.ToString(), ProductsName, ProductsPrice.ToString(), CategoryID.ToString(), CategoryName }); db.ExecSQL(sql); } else { ErrorMsg = Pub.GetResText(formCode, "Error004", ""); return(false); } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E, sql); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return(false); } db.WriteSYLog(this.Text, CurrentTool, sql); return(ret); }
private bool ReadCard(bool ReadAll) { CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return(false); } pubData = new QHAPI.TCardPubData(); skData = new QHAPI.TCardSKData(); if (!Pub.ReadCardInfo(ref pubData)) { return(false); } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { return(false); } if (!Pub.ReadCardInfo(ref skData)) { return(false); } DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { return(false); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardRefunNotNormal", "")); } else { txtEmpNo.Text = dr["EmpNo"].ToString(); txtEmpName.Text = dr["EmpName"].ToString(); txtDepartName.Text = dr["DepartName"].ToString(); txtCardSectorNo.Text = dr["CardSectorNo"].ToString(); txtCardStatusName.Text = dr["CardStatusName"].ToString(); txtCardType.Text = dr["CardTypeName"].ToString(); IsOk = true; } } else { Pub.MessageBoxShow(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } return(IsOk); }
public Vales ObtenerValeDetalleCorreos(Vales Datos) { try { Vales Resultado = new Vales(); DataSet Ds = SqlHelper.ExecuteDataset(Datos.Conexion, "spCSLDB_get_ValesEnvioCorreos", Datos.IDVale); if (Ds != null) { if (Ds.Tables.Count == 2) { DataTableReader Dr = Ds.Tables[0].CreateDataReader(); while (Dr.Read()) { Resultado.IDVale = !Dr.IsDBNull(Dr.GetOrdinal("id_vale")) ? Dr.GetString(Dr.GetOrdinal("id_vale")) : string.Empty; Resultado.IDTipoVale = !Dr.IsDBNull(Dr.GetOrdinal("id_tipoVale")) ? Dr.GetInt32(Dr.GetOrdinal("id_tipoVale")) : 0; Resultado.IDEstatusVale = !Dr.IsDBNull(Dr.GetOrdinal("id_estatusVale")) ? Dr.GetInt32(Dr.GetOrdinal("id_estatusVale")) : 0; Resultado.Nombre = !Dr.IsDBNull(Dr.GetOrdinal("Titulo")) ? Dr.GetString(Dr.GetOrdinal("Titulo")) : string.Empty; Resultado.Folio = !Dr.IsDBNull(Dr.GetOrdinal("folio")) ? Dr.GetString(Dr.GetOrdinal("folio")) : string.Empty; Resultado.CantLimite = !Dr.IsDBNull(Dr.GetOrdinal("cantLimite")) ? Dr.GetInt32(Dr.GetOrdinal("cantLimite")) : 0; Resultado.Abierto = !Dr.IsDBNull(Dr.GetOrdinal("abierto")) ? Dr.GetBoolean(Dr.GetOrdinal("abierto")) : false; Resultado.RequierePeriodo = !Dr.IsDBNull(Dr.GetOrdinal("rangoFechas")) ? Dr.GetBoolean(Dr.GetOrdinal("rangoFechas")) : false; switch (Resultado.IDTipoVale) { case 1: case 2: Resultado.Monto = !Dr.IsDBNull(Dr.GetOrdinal("monto")) ? Dr.GetDecimal(Dr.GetOrdinal("monto")) : 0; Resultado.Porcentaje = !Dr.IsDBNull(Dr.GetOrdinal("porcentaje")) ? Dr.GetDecimal(Dr.GetOrdinal("porcentaje")) : 0; if (Resultado.RequierePeriodo) { Resultado.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("fechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("fechaInicio")) : DateTime.Today; Resultado.FechaFin = !Dr.IsDBNull(Dr.GetOrdinal("fechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("fechaFin")) : DateTime.Today; } else { Resultado.Lunes = !Dr.IsDBNull(Dr.GetOrdinal("lunes")) ? Dr.GetBoolean(Dr.GetOrdinal("lunes")) : false; Resultado.Martes = !Dr.IsDBNull(Dr.GetOrdinal("martes")) ? Dr.GetBoolean(Dr.GetOrdinal("martes")) : false; Resultado.Miercoles = !Dr.IsDBNull(Dr.GetOrdinal("miercoles")) ? Dr.GetBoolean(Dr.GetOrdinal("miercoles")) : false; Resultado.Jueves = !Dr.IsDBNull(Dr.GetOrdinal("jueves")) ? Dr.GetBoolean(Dr.GetOrdinal("jueves")) : false; Resultado.Viernes = !Dr.IsDBNull(Dr.GetOrdinal("viernes")) ? Dr.GetBoolean(Dr.GetOrdinal("viernes")) : false; Resultado.Sabado = !Dr.IsDBNull(Dr.GetOrdinal("sabado")) ? Dr.GetBoolean(Dr.GetOrdinal("sabado")) : false; Resultado.Domingo = !Dr.IsDBNull(Dr.GetOrdinal("domingo")) ? Dr.GetBoolean(Dr.GetOrdinal("domingo")) : false; } break; case 3: string IDProductoNXN = !Dr.IsDBNull(Dr.GetOrdinal("id_productoRequerido")) ? Dr.GetString(Dr.GetOrdinal("id_productoRequerido")) : string.Empty; string ClaveNxN = !Dr.IsDBNull(Dr.GetOrdinal("ClaveN")) ? Dr.GetString(Dr.GetOrdinal("ClaveN")) : string.Empty; string NombreProductoNXN = !Dr.IsDBNull(Dr.GetOrdinal("ProductoN")) ? Dr.GetString(Dr.GetOrdinal("ProductoN")) : string.Empty; byte[] ImagenProductoNXN = (byte[])Dr.GetValue(Dr.GetOrdinal("ImagenProductoN")); string NombreImagen = !Dr.IsDBNull(Dr.GetOrdinal("url_imagen")) ? Dr.GetString(Dr.GetOrdinal("url_imagen")) : string.Empty; Resultado.ProductoRequerido = new Producto { IDProducto = IDProductoNXN, NombreProducto = NombreProductoNXN, Imagen = ImagenProductoNXN, UrlImagen = NombreImagen, Clave = ClaveNxN }; Resultado.CantidadRequeridaNxN = !Dr.IsDBNull(Dr.GetOrdinal("cantRequerida")) ? Dr.GetInt32(Dr.GetOrdinal("cantRequerida")) : 0; Resultado.CantidadGratisNxN = !Dr.IsDBNull(Dr.GetOrdinal("cantGratis")) ? Dr.GetInt32(Dr.GetOrdinal("cantGratis")) : 0; if (Resultado.RequierePeriodo) { Resultado.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("fechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("fechaInicio")) : DateTime.Today; Resultado.FechaFin = !Dr.IsDBNull(Dr.GetOrdinal("fechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("fechaFin")) : DateTime.Today; } else { Resultado.Lunes = !Dr.IsDBNull(Dr.GetOrdinal("lunes")) ? Dr.GetBoolean(Dr.GetOrdinal("lunes")) : false; Resultado.Martes = !Dr.IsDBNull(Dr.GetOrdinal("martes")) ? Dr.GetBoolean(Dr.GetOrdinal("martes")) : false; Resultado.Miercoles = !Dr.IsDBNull(Dr.GetOrdinal("miercoles")) ? Dr.GetBoolean(Dr.GetOrdinal("miercoles")) : false; Resultado.Jueves = !Dr.IsDBNull(Dr.GetOrdinal("jueves")) ? Dr.GetBoolean(Dr.GetOrdinal("jueves")) : false; Resultado.Viernes = !Dr.IsDBNull(Dr.GetOrdinal("viernes")) ? Dr.GetBoolean(Dr.GetOrdinal("viernes")) : false; Resultado.Sabado = !Dr.IsDBNull(Dr.GetOrdinal("sabado")) ? Dr.GetBoolean(Dr.GetOrdinal("sabado")) : false; Resultado.Domingo = !Dr.IsDBNull(Dr.GetOrdinal("domingo")) ? Dr.GetBoolean(Dr.GetOrdinal("domingo")) : false; } break; case 4: string IDProductoM = !Dr.IsDBNull(Dr.GetOrdinal("id_productoRequerido")) ? Dr.GetString(Dr.GetOrdinal("id_productoRequerido")) : string.Empty; string ClaveM = !Dr.IsDBNull(Dr.GetOrdinal("ClaveM")) ? Dr.GetString(Dr.GetOrdinal("ClaveM")) : string.Empty; string NombreProductoM = !Dr.IsDBNull(Dr.GetOrdinal("ProductoM")) ? Dr.GetString(Dr.GetOrdinal("ProductoM")) : string.Empty; byte[] ImagenProductoM = (byte[])Dr.GetValue(Dr.GetOrdinal("ImagenProductoM")); string NombreImagenM = !Dr.IsDBNull(Dr.GetOrdinal("UrlImagenProductoM")) ? Dr.GetString(Dr.GetOrdinal("UrlImagenProductoM")) : string.Empty; string IDProductoN = !Dr.IsDBNull(Dr.GetOrdinal("id_productoGratis")) ? Dr.GetString(Dr.GetOrdinal("id_productoGratis")) : string.Empty; string ClaveN = !Dr.IsDBNull(Dr.GetOrdinal("ClaveN")) ? Dr.GetString(Dr.GetOrdinal("ClaveN")) : string.Empty; string NombreProductoN = !Dr.IsDBNull(Dr.GetOrdinal("ProductoN")) ? Dr.GetString(Dr.GetOrdinal("ProductoN")) : string.Empty; byte[] ImagenProductoN = (byte[])Dr.GetValue(Dr.GetOrdinal("ImagenProductoN")); string NombreImagenN = !Dr.IsDBNull(Dr.GetOrdinal("UrlImagenProductoN")) ? Dr.GetString(Dr.GetOrdinal("UrlImagenProductoN")) : string.Empty; Resultado.ProductoRequerido = new Producto { IDProducto = IDProductoM, NombreProducto = NombreProductoM, Imagen = ImagenProductoM, UrlImagen = NombreImagenM, Clave = ClaveM }; Resultado.CantRequeridad = !Dr.IsDBNull(Dr.GetOrdinal("cantRequerida")) ? Dr.GetInt32(Dr.GetOrdinal("cantRequerida")) : 0; Resultado.ProductoGratis = new Producto { IDProducto = IDProductoN, NombreProducto1 = NombreProductoN, ImagenProductoN = ImagenProductoN, UrlImagenN = NombreImagenN, ClaveN = ClaveN }; Resultado.CantGratis = !Dr.IsDBNull(Dr.GetOrdinal("cantGratis")) ? Dr.GetInt32(Dr.GetOrdinal("cantGratis")) : 0; if (Resultado.RequierePeriodo) { Resultado.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("fechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("fechaInicio")) : DateTime.Today; Resultado.FechaFin = !Dr.IsDBNull(Dr.GetOrdinal("fechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("fechaFin")) : DateTime.Today; } else { Resultado.Lunes = !Dr.IsDBNull(Dr.GetOrdinal("lunes")) ? Dr.GetBoolean(Dr.GetOrdinal("lunes")) : false; Resultado.Martes = !Dr.IsDBNull(Dr.GetOrdinal("martes")) ? Dr.GetBoolean(Dr.GetOrdinal("martes")) : false; Resultado.Miercoles = !Dr.IsDBNull(Dr.GetOrdinal("miercoles")) ? Dr.GetBoolean(Dr.GetOrdinal("miercoles")) : false; Resultado.Jueves = !Dr.IsDBNull(Dr.GetOrdinal("jueves")) ? Dr.GetBoolean(Dr.GetOrdinal("jueves")) : false; Resultado.Viernes = !Dr.IsDBNull(Dr.GetOrdinal("viernes")) ? Dr.GetBoolean(Dr.GetOrdinal("viernes")) : false; Resultado.Sabado = !Dr.IsDBNull(Dr.GetOrdinal("sabado")) ? Dr.GetBoolean(Dr.GetOrdinal("sabado")) : false; Resultado.Domingo = !Dr.IsDBNull(Dr.GetOrdinal("domingo")) ? Dr.GetBoolean(Dr.GetOrdinal("domingo")) : false; } break; } } Dr.Close(); DataTable TablaAUx = Ds.Tables[1]; DataTableReader Dr2 = Ds.Tables[1].CreateDataReader(); List <Producto> Lista = new List <Producto>(); Producto Item; while (Dr2.Read()) { Item = new Producto(); Item.IDProducto = Dr2.GetString(Dr2.GetOrdinal("IDProducto")); Item.Clave = Dr2.GetString(Dr2.GetOrdinal("Clave")); Item.NombreProducto = Dr2.GetString(Dr2.GetOrdinal("NombreProducto")); if (Convert.IsDBNull(Dr2.GetValue(Dr2.GetOrdinal("ImagenProducto")))) { Item.Imagen = new byte[0]; } else { Item.Imagen = (byte[])Dr2["ImagenProducto"]; } Item.UrlImagen = Dr2.GetString(Dr2.GetOrdinal("url_imagen")); Lista.Add(Item); } Resultado.ListaProductos = Lista; Dr2.Close(); } } return(Resultado); } catch (Exception ex) { throw ex; } }
/// <summary> /// Retorna datos para dibujado de la página carrito /// </summary> /// <param name="_datos">Objeto con datos de conexión y parámetros </param> public CH_Carrito ObtenerDatosPaginaCarrito(string _idCliente, bool _esAnonimo, string _conexion) { try { CH_Carrito dataResult = new CH_Carrito(); object[] parametros = { _idCliente, _esAnonimo }; DataSet ds = SqlHelper.ExecuteDataset(_conexion, "CH_spCSLDB_get_DatosCarrito", parametros); if (ds != null) { if (ds.Tables.Count == 4) { DataTableReader dr = ds.Tables[0].CreateDataReader(); List <CH_Textos> listaTextos = new List <CH_Textos>(); CH_Textos itemTexto; while (dr.Read()) { itemTexto = new CH_Textos(); itemTexto.Texto = dr.GetString(dr.GetOrdinal("Texto")); itemTexto.NumPosition = dr.GetInt32(dr.GetOrdinal("NumPosition")); listaTextos.Add(itemTexto); } dataResult.ListaTextos = listaTextos; DataTableReader drImg = ds.Tables[1].CreateDataReader(); List <CH_Imagen> listaImagenes = new List <CH_Imagen>(); CH_Imagen itemImagen; while (drImg.Read()) { itemImagen = new CH_Imagen(); itemImagen.Alt = drImg.GetString(drImg.GetOrdinal("TextoAlternativo")); itemImagen.Title = drImg.GetString(drImg.GetOrdinal("TituloImagen")); itemImagen.UrlImagen = drImg.GetString(drImg.GetOrdinal("UrlImagen")); itemImagen.NumPosition = drImg.GetInt32(drImg.GetOrdinal("NumPosition")); listaImagenes.Add(itemImagen); } dataResult.ListaImagenes = listaImagenes; DataTableReader drCart = ds.Tables[2].CreateDataReader(); while (drCart.Read()) { dataResult.IdCarrito = drCart.GetString(drCart.GetOrdinal("id_carrito")); dataResult.Subtotal = drCart.GetDecimal(drCart.GetOrdinal("subtotal")); dataResult.Descuento = drCart.GetDecimal(drCart.GetOrdinal("descuento")); dataResult.Total = drCart.GetDecimal(drCart.GetOrdinal("total")); dataResult.CodigoVale = drCart.GetString(drCart.GetOrdinal("Vale")); break; } DataTableReader drVD = ds.Tables[3].CreateDataReader(); List <CH_VentaDetalle> listaVD = new List <CH_VentaDetalle>(); CH_VentaDetalle itemVD; while (drVD.Read()) { itemVD = new CH_VentaDetalle(); itemVD.IdCarritoDetalle = drVD.GetString(drVD.GetOrdinal("IDCarritoDetalle")); itemVD.Producto.IdProducto = drVD.GetString(drVD.GetOrdinal("IDProducto")); itemVD.Producto.NombreProducto = drVD.GetString(drVD.GetOrdinal("NombreProducto")); itemVD.Cantidad = drVD.GetInt32(drVD.GetOrdinal("cantidad")); itemVD.PrecioVenta = drVD.GetDecimal(drVD.GetOrdinal("Precio")); itemVD.Importe = drVD.GetDecimal(drVD.GetOrdinal("importe")); itemVD.Descuento = drVD.GetDecimal(drVD.GetOrdinal("descuento")); itemVD.Total = drVD.GetDecimal(drVD.GetOrdinal("total")); itemVD.Producto.Talla.IdTalla = drVD.GetInt32(drVD.GetOrdinal("IDTalla")); itemVD.Producto.Color.IdColor = drVD.GetInt32(drVD.GetOrdinal("IDColor")); listaVD.Add(itemVD); } dataResult.ListaVentaDetalle = listaVD; dataResult.Completado = true; } } return(dataResult); } catch (Exception ex) { throw ex; } }
public void MultipleResultSetsTest() { DataTable dt1 = new DataTable("test2"); dt1.Columns.Add("x", typeof(string)); dt1.Rows.Add(new object[] { "test" }); dt1.Rows.Add(new object[] { "test1" }); dt1.AcceptChanges(); DataTable[] collection = new DataTable[] { _dt, dt1 }; DataTableReader reader = new DataTableReader(collection); try { int i = 0; do { while (reader.Read()) i++; } while (reader.NextResult()); Assert.Equal(5, i); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public void CloseTest() { Assert.Throws<InvalidOperationException>(() => { DataTableReader reader = new DataTableReader(_dt); try { int i = 0; while (reader.Read() && i < 1) i++; reader.Close(); reader.Read(); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
private void btnOk_Click(object sender, EventArgs e) { string MacSN = ""; string IP = ""; string MacConnType = MacConnTypeString.LAN; string MacPort = ""; byte MacType = 0; byte IsBigMac = 0; string s = ""; DataTableReader dr = null; List <string> sql = new List <string>(); for (int i = 0; i < dataGrid.RowCount; i++) { MacSN = dataGrid[1, i].Value.ToString(); IP = dataGrid[3, i].Value.ToString(); MacPort = dataGrid[7, i].Value.ToString(); IsBigMac = Convert.ToByte(dataGrid[2, i].Value); try { if (FindType == 0) { if (SystemInfo.IsNewMJ) { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "1004", MacSN })); } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "5", MacSN })); } if (!dr.Read()) { byte MacDoorType = 0; if (SystemInfo.IsNewMJ) { MacDoorType = Convert.ToByte(MacSN.Substring(1, 1)); sql.Add(Pub.GetSQL(DBCode.DB_003001, new string[] { "1", MacSN, MacDoorType.ToString(), MacConnType, IP, MacPort, "", "", SystemInfo.CardProtocol.ToString() })); } else { MacDoorType = Convert.ToByte(MacSN.Substring(0, 2)); sql.Add(Pub.GetSQL(DBCode.DB_003001, new string[] { "1", MacSN.Substring(2), MacDoorType.ToString(), MacConnType, IP, MacPort, "", "", SystemInfo.CardProtocol.ToString() })); } } } else if (FindType == 1) { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "5", MacSN })); if (!dr.Read()) { sql.Add(Pub.GetSQL(DBCode.DB_002001, new string[] { "1", MacSN, SystemInfo.CardType.ToString(), MacConnType, IP, MacPort, "", "", "", IsBigMac.ToString() })); } } else if (FindType == 2) { s = dataGrid.SelectedRows[0].Cells[4].Value.ToString(); if (!Pub.IsNumeric(s)) { s = s.Substring(1, 2); } MacType = Convert.ToByte(s); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004004, new string[] { "5", MacSN })); if (!dr.Read()) { sql.Add(Pub.GetSQL(DBCode.DB_004004, new string[] { "1", MacSN, MacType.ToString(), MacConnType, IP, MacPort, "", "", "", "", IsBigMac.ToString() })); } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } } if (sql.Count > 0) { if (db.ExecSQL(sql) != 0) { return; } db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); } this.DialogResult = DialogResult.OK; this.Close(); }
public void AccessAfterClosedTest() { Assert.Throws<InvalidOperationException>(() => { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); reader.Close(); int i = (int)reader[0]; i++; // to supress warning } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
protected void Page_Load(object sender, EventArgs e) { //Check to see if the user is logged in else redirect them to the login page if (Request.Cookies["LoggedInCookie"] == null || (Request.Cookies["LoggedInCookie"] != null && Request.Cookies["LoggedInCookie"]["LoggedIn"] != "true")) { Response.Redirect("Register.aspx"); } if (!IsPostBack) { //Set the button events logoutImgBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/LogoutMouseOver.png'"); logoutImgBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/LogOutDefault.png'"); PasswordImgBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/ChangePasswordMouseOver.jpg'"); PasswordImgBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/ChangePasswordDefault.jpg'"); SubmitImgBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/SubmitABookMouseOver.jpg'"); SubmitImgBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/SubmitABookDefault.jpg'"); UpdateBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/UpdateMouseOver.png'"); UpdateBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/UpdateDefault.png'"); RecoverPassImgBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/RecoverPasswordMouseOver.jpg'"); RecoverPassImgBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/RecoverPasswordDefault.jpg'"); //Databind the security question to the drop down list //Create a new instance of the class containing the list of security questions: /App_code/ArrayCollections.cs ArrayList SecurityQuestionsList = new ArrayList(); ArrayCollections getlist = new ArrayCollections(); SecurityQuestionsList = getlist.SecurityQuestions(); //Set as the datasource SecurityQuestionDdl.DataSource = SecurityQuestionsList; //DataBind SecurityQuestionDdl.DataBind(); //Set the textbox values to the userInfo from the database/Check to see the update report //Once a new instance of the service Service BookWormService = new Service(); //Query against the database and store the dataset as a dataReader DataTableReader UserInfo = BookWormService.ExecuteQuery("SELECT [UserName],[UserPassword],[UserEmail],[UserAnswer],[UserQuestion] FROM [UserInformation] WHERE [UserId] = '" + Request.Cookies["LoggedInCookie"]["UserId"].ToString() + "'").CreateDataReader(); //Read from the dataset and apply the values to the lables while (UserInfo.Read()) { UserNameTxtb.Text = UserInfo.GetString(0); UserNameHeaderLble.Text = UserInfo.GetString(0); EmailTxtb.Text = UserInfo.GetString(2); SecurityAnswerTxtb.Text = UserInfo.GetString(3); SecurityQuestionDdl.SelectedValue = UserInfo.GetString(4); } //Set the gridView to select all books containig the users Id SubmittedGV.DataSource = BookWormService.ExecuteQuery("SELECT [BookImageUrl] , [BookId] , [BookName] FROM [BookInformation] WHERE [BookSubmiterId] = '" + Request.Cookies["LoggedInCookie"]["UserId"] + "'"); SubmittedGV.DataBind(); //Close the connection to the database UserInfo.Close(); //Clear the resources BookWormService.Dispose(); } // disply the report if the user has tried to update thier profile if (Session["UpDateReport"] != null) { //Make sure no values are carried over UpdateReportLble.Text = ""; if (Session["UpDateReport"].ToString() == "True") { UpdateReportLble.Text = "Update Successful!"; } else { UpdateReportLble.Text = "Something went wrong, try again in a few minuttes."; } } //Make sure no values are carried over Session["UpDateReport"] = null; }
public void DeletePreviousAndAcceptChangesTest() { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row reader.Read(); // second row _dt.Rows[0].Delete(); _dt.AcceptChanges(); Assert.Equal(2, (int)reader[0]); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public EstadisticosAfiliados ObtenerEstadisticosAfiliados(string Conexion) { try { EstadisticosAfiliados Result = new EstadisticosAfiliados(); DataSet Ds = SqlHelper.ExecuteDataset(Conexion, "INE_spCSLDB_get_EstadisticosAfiliados"); if (Ds != null) { if (Ds.Tables.Count == 4) { DataTableReader Dr = Ds.Tables[0].CreateDataReader(); while (Dr.Read()) { Result.Completado = true; Result.FechaUltimoAfiliado = !Dr.IsDBNull(Dr.GetOrdinal("FechaUltimoAfiliado")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaUltimoAfiliado")) : DateTime.MinValue; Result.TiempoTranscurridoUAHoras = !Dr.IsDBNull(Dr.GetOrdinal("TiempoTranscurridoUAHoras")) ? Dr.GetInt32(Dr.GetOrdinal("TiempoTranscurridoUAHoras")) : 0; Result.PorcentajeAfiliados = !Dr.IsDBNull(Dr.GetOrdinal("PorcentajeAfiliados")) ? Dr.GetInt32(Dr.GetOrdinal("PorcentajeAfiliados")) : 0; Result.PromedioInscripcionXDia = !Dr.IsDBNull(Dr.GetOrdinal("PromedioInscripcionXDia")) ? Dr.GetInt32(Dr.GetOrdinal("PromedioInscripcionXDia")) : 0; Result.MetaCampania = !Dr.IsDBNull(Dr.GetOrdinal("MetaCampania")) ? Dr.GetInt32(Dr.GetOrdinal("MetaCampania")) : 0; Result.AfiliadosInscritos = !Dr.IsDBNull(Dr.GetOrdinal("AfiliadosInscritos")) ? Dr.GetInt32(Dr.GetOrdinal("AfiliadosInscritos")) : 0; Result.AfiliadosValidos = !Dr.IsDBNull(Dr.GetOrdinal("AfiliadosValidos")) ? Dr.GetInt32(Dr.GetOrdinal("AfiliadosValidos")) : 0; Result.AfiliadosRechazados = !Dr.IsDBNull(Dr.GetOrdinal("AfiliadosRechazados")) ? Dr.GetInt32(Dr.GetOrdinal("AfiliadosRechazados")) : 0; Result.SeccionesConcluidas = !Dr.IsDBNull(Dr.GetOrdinal("SeccionesConcluidas")) ? Dr.GetInt32(Dr.GetOrdinal("SeccionesConcluidas")) : 0; Result.SeccionesFaltantes = !Dr.IsDBNull(Dr.GetOrdinal("SeccionesFaltantes")) ? Dr.GetInt32(Dr.GetOrdinal("SeccionesFaltantes")) : 0; Result.PorcentajeAvanceSeccion = !Dr.IsDBNull(Dr.GetOrdinal("PorcentajeSecciones")) ? Dr.GetInt32(Dr.GetOrdinal("PorcentajeSecciones")) : 0; break; } DataTableReader Dr2 = Ds.Tables[1].CreateDataReader(); List <EstadisticosRepresentantesSeccion> Lista = new List <EstadisticosRepresentantesSeccion>(); EstadisticosRepresentantesSeccion Item; while (Dr2.Read()) { Item = new EstadisticosRepresentantesSeccion(); Item.Seccion = !Dr2.IsDBNull(Dr2.GetOrdinal("id_seccion")) ? Dr2.GetInt32(Dr2.GetOrdinal("id_seccion")) : 0; Item.Nombre = !Dr2.IsDBNull(Dr2.GetOrdinal("Representante")) ? Dr2.GetString(Dr2.GetOrdinal("Representante")) : string.Empty; Item.Imagen = !Dr2.IsDBNull(Dr2.GetOrdinal("Imagen")) ? Dr2.GetString(Dr2.GetOrdinal("Imagen")) : string.Empty; Item.Avance = !Dr2.IsDBNull(Dr2.GetOrdinal("Avance")) ? Dr2.GetInt32(Dr2.GetOrdinal("Avance")) : 0; Item.CssClass = !Dr2.IsDBNull(Dr2.GetOrdinal("CssClass")) ? Dr2.GetString(Dr2.GetOrdinal("CssClass")) : string.Empty; Lista.Add(Item); } Result.Lista = Lista; Result.TablaSecciones = Ds.Tables[2]; DataTableReader Dr3 = Ds.Tables[3].CreateDataReader(); while (Dr3.Read()) { Result.SeccionesMayorAvance = !Dr3.IsDBNull(Dr3.GetOrdinal("SeccionesMayorAvance")) ? Dr3.GetString(Dr3.GetOrdinal("SeccionesMayorAvance")) : string.Empty; Result.SeccionesMenorAvance = !Dr3.IsDBNull(Dr3.GetOrdinal("SeccionesMenorAvance")) ? Dr3.GetString(Dr3.GetOrdinal("SeccionesMenorAvance")) : string.Empty; break; } } } return(Result); } catch (Exception ex) { throw ex; } }
public void ClearTest() { DataTableReader reader = null; try { reader = new DataTableReader(_dt); reader.Read(); // first row reader.Read(); // second row _dt.Clear(); try { int i = (int)reader[0]; i++; // supress warning Assert.False(true); } catch (RowNotInTableException) { } // clear and add test reader.Close(); reader = new DataTableReader(_dt); reader.Read(); // first row reader.Read(); // second row _dt.Clear(); _dt.Rows.Add(new object[] { 8, "mono 8" }); _dt.AcceptChanges(); bool success = reader.Read(); Assert.False(success); // clear when reader is not read yet reader.Close(); reader = new DataTableReader(_dt); _dt.Clear(); _dt.Rows.Add(new object[] { 8, "mono 8" }); _dt.AcceptChanges(); success = reader.Read(); Assert.True(success); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void Btnsave_Click(object sender, EventArgs e) { SqlDataReader reader; object pIPAddress; string str = ""; System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(str); IPAddress[] addr = ipEntry.AddressList; pIPAddress = addr[addr.Length - 1].ToString(); string currentpass = Encryptor.EnDe_crypt(txtcurrentpass.Text, true); string newpass = Encryptor.EnDe_crypt(txtnewpass.Text, true); string confirmpass = Encryptor.EnDe_crypt(txtconfirm.Text, true); string spName = "exec sp_Changepass"; string Userid = "'" + userid + "'"; string parmcurrentpass = "******" + currentpass + "'"; string parmnewpass = "******" + newpass + "'"; string parmpIPAddress = "'" + pIPAddress + "'"; //string strSQL = "exec sp_ScannerChangepass" + " '" + userid + "','" + currentpass + "','" + newpass + "','" + pIPAddress + "'"; if (currentpass != "v8x/nZtWOrw=") { if (currentpass != newpass) { if (newpass == confirmpass) { string strSQL = "exec sp_Changepass" + " '" + userid + "','" + currentpass + "','" + newpass + "','" + pIPAddress + "'"; //reader = GenericFunc.ExecuteReader(spName, Userid, parmcurrentpass, parmnewpass, parmpIPAddress); DataTable data = new DataTable(); DataTableReader readesr = GenericFunc.MSsqlDataReader(strConnection, strSQL); //data.Load(reader); //Result = data.Rows[0]["Result"].ToString(); //Result = data.Rows[0]["Result"].ToString(); if (readesr.Read()) { Result = readesr["Result"].ToString(); //strUsrBranch = reader["Branch"].ToString(); } ChangeResult = Result; if (Result == "0") { MessageBox.Show("Successfully Changed"); this.Close(); } else if (Result == "1") { MessageBox.Show("Incorrect Current Password"); } } else { MessageBox.Show("New password and Confirm password not Matched"); } } else { MessageBox.Show("Current password and New password Matched"); } } else { MessageBox.Show("Please Enter Current password, New Password and Confirm Password"); } }
private bool CheckData(int flag, DateTime CheckOutDate, ref int DepositCount, ref double DepositSum, ref double DepositDiscount, ref double GiftCount, ref int RefundmentCount, ref double RefundmentSum, ref int EliminateCount, ref double EliminateSum, ref double BTSum, ref double ZeroSum, ref double NormalDZSum, ref double NormalJZSum, ref double InCardFee, ref double ToCardFee, ref double CardSum, ref double BTWSum) { bool ret = false; DataTableReader dr = null; int SFType = 0; int times = 0; double money = 0; double CardSumLast = 0; //double DepositDiscountLast = 0; //double GiftCountLast = 0; double ErrorCorrection = 0; string sql = ""; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004007, new string[] { "7" })); if (dr.Read()) { double.TryParse(dr[0].ToString(), out CardSumLast); //double.TryParse(dr[1].ToString(), out DepositDiscountLast); //double.TryParse(dr[2].ToString(), out GiftCountLast); } dr.Close(); if (flag == 0) { sql = Pub.GetSQL(DBCode.DB_004007, new string[] { "3", CheckOutDate.AddDays(1).ToString(SystemInfo.SQLDateFMT) }); } else { sql = Pub.GetSQL(DBCode.DB_004007, new string[] { "3" }); } dr = db.GetDataReader(sql); while (dr.Read()) { int.TryParse(dr["SFTypeID"].ToString(), out SFType); int.TryParse(dr["CountTimes"].ToString(), out times); double.TryParse(dr["SumSFAmount"].ToString(), out money); if (SFType == 0)//补贴清零 { ZeroSum += money; } else if ((SFType == 1) || (SFType == 3) || (SFType == 6) || (SFType == 7) || (SFType == 8) || (SFType == 60) || (SFType == 130)) //扣款消费 { NormalDZSum += money; } else if (SFType == 2)//记帐消费 { NormalJZSum += money; } else if ((SFType == 4) || (SFType == 10) || (SFType >= 90 && SFType <= 99) || (SFType >= 100 && SFType <= 109))//充值 { DepositCount += times; DepositSum += money; } else if (SFType == 5)//补贴金额 { BTSum += money; } else if ((SFType == 9) || (SFType == 20) || (SFType == 21) || (SFType >= 200 && SFType <= 209))//取款 { RefundmentCount += times; RefundmentSum += money; } else if (SFType == 30)//销户 { EliminateCount += times; EliminateSum += money; } else if (SFType == 40)//收工本费 { InCardFee += money; } else if (SFType == 50)//退工本费 { ToCardFee += money; } else if (SFType == 70) //充值折扣 { DepositDiscount += money; } else if (SFType == 80)//充值赠送 { GiftCount += money; } else if (SFType == 120)//消费纠错 { ErrorCorrection += money; } } dr.Close(); if (flag == 0) { sql = Pub.GetSQL(DBCode.DB_004007, new string[] { "20", CheckOutDate.AddDays(1).ToString(SystemInfo.SQLDateFMT) }); } else { sql = Pub.GetSQL(DBCode.DB_004007, new string[] { "20" }); } dr = db.GetDataReader(sql); while (dr.Read()) { if (SFType == 130)//餐次补贴 { BTWSum += money; } } ret = true; } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } //DepositDiscount += DepositDiscountLast; //GiftCount += GiftCountLast; //double CashIncome = DepositSum + InCardFee; //现金收入 //double CashOut = RefundmentSum + EliminateSum + ToCardFee; //现金支出(算工本费) double CashIncome = DepositSum; //现金收入 double CashOut = RefundmentSum + EliminateSum; //现金支出 double Income = CashIncome - CashOut; //净收入 double Consumer = NormalDZSum; //消费汇总 CardSum = CardSumLast + Income + BTSum + DepositDiscount + GiftCount + ErrorCorrection - ZeroSum - Consumer; //当期结余 CardSum = Math.Round(CardSum, 2); return(ret); }
private void btnExcluir_Click(object sender, EventArgs e) { if (this.dgvCargos.Rows.Count > 0) { if (txtCodigo.Text != "") { DialogResult result = MessageBox.Show("Confirma a exclusão dos dados selecionados?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { clsCargo objCargo = new clsCargo(); objCargo.Numero = Convert.ToInt32(txtCodigo.Text); objCargo.Excluir(objCargo); controlaBotoes(true); AtualizaGrid(); zeraDados(); //MessageBox.Show("Dados excluídos com sucesso.", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { //MessageBox.Show("Dados não foram excluídos. \n" + ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } DataTableReader Dados = new DataTableReader(clsFuncionario.recuperarTodosComCargoSetor()); bool ok = false; while (Dados.Read()) { if (Dados.GetInt32(8) == Convert.ToInt32(txtCodigo.Text)) { ok = true; break; } } controlaBotoes(true); AtualizaGrid(); zeraDados(); if (ok == true) { MessageBox.Show("Existe(m) funcionário(s) com este cargo.\nDados não foram excluídos. \n", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Dados excluídos com sucesso.", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { zeraDados(); } } else { MessageBox.Show(this, "Selecione um registro para excluir", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Sem dados registrados para excluir", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnOk_Click(object sender, EventArgs e) { DataTableReader dr = null; bool IsOk = false; string sql = ""; if (!CheckValue()) { return; } try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (SysID == "") { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "2004", MacSN_GPRS })); if (dr.Read()) { txtMacSN.Focus(); ShowErrorCannotRepeated(lblMacSN.Text); } else { sql = Pub.GetSQL(DBCode.DB_002001, new string[] { "2005", MacSN_GPRS, "3", "", MacConnType, MacIPAddress, MacPort, MacConnPWD, MacDesc, MacPhysicsAddress, Convert.ToByte(IsGPRS).ToString() }); db.ExecSQL(sql); IsOk = true; } } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "2006", SysID, MacSN_GPRS })); if (dr.Read()) { txtMacSN.Focus(); ShowErrorCannotRepeated(lblMacSN.Text); } else { sql = Pub.GetSQL(DBCode.DB_002001, new string[] { "2007", MacSN_GPRS, "3", "", MacConnType, MacIPAddress, MacPort, MacConnPWD, MacDesc, MacPhysicsAddress, Convert.ToByte(IsGPRS).ToString(), SysID }); db.ExecSQL(sql); IsOk = true; } } } catch (Exception E) { Pub.ShowErrorMsg(E, sql); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk) { db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } }
private void LoadData() { cbbSun.Items.Clear(); cbbMon.Items.Clear(); cbbTue.Items.Clear(); cbbWed.Items.Clear(); cbbThu.Items.Clear(); cbbFri.Items.Clear(); cbbSat.Items.Clear(); cbbSun.Items.Add("0"); cbbMon.Items.Add("0"); cbbTue.Items.Add("0"); cbbWed.Items.Add("0"); cbbThu.Items.Add("0"); cbbFri.Items.Add("0"); cbbSat.Items.Add("0"); DataTableReader dr = null; TIDAndName idn; try { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "400" })); while (dr.Read()) { idn = new TIDAndName(dr["PassTimeID"].ToString(), "[" + dr["PassTimeID"].ToString() + "]" + dr["PassTimeName"].ToString()); cbbSun.Items.Add(idn); cbbMon.Items.Add(idn); cbbTue.Items.Add(idn); cbbWed.Items.Add(idn); cbbThu.Items.Add(idn); cbbFri.Items.Add(idn); cbbSat.Items.Add(idn); } dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "8" })); int rowindex = 0; while (dr.Read()) { macGrid.Rows.Add(); macGrid[0, rowindex].Value = true; macGrid[1, rowindex].Value = dr["MacSN"].ToString(); macGrid[2, rowindex].Value = dr["MacDesc"].ToString(); rowindex++; } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } int index = 0; if (cbbFri.Items.Count > 0) { index = 1; } cbbSun.SelectedIndex = index; cbbMon.SelectedIndex = index; cbbTue.SelectedIndex = index; cbbWed.SelectedIndex = index; cbbThu.SelectedIndex = index; cbbFri.SelectedIndex = index; cbbSat.SelectedIndex = index; }
private bool AddSubDirs(TreeNode ParentNode, string ParentPath) { bool ret = false; DataTableReader dr = null; TreeNode tn; string tmp = ""; if ((ParentNode.Nodes.Count > 0) && (ParentNode.Nodes[0].Text == "")) { ParentNode.Nodes.Clear(); if (UseLocal) { DirectoryInfo Folder = new DirectoryInfo(ParentPath); foreach (DirectoryInfo NextFolder in Folder.GetDirectories()) { tmp = NextFolder.Name; tn = ParentNode.Nodes.Add(tmp); tn.ImageIndex = 0; tn.SelectedImageIndex = 1; tn.Tag = "0"; tn.Nodes.Add(""); tn.Tag = tn.Tag.ToString() + GetFullPath(tn); } if (!OnlyPath) { foreach (FileInfo NextFile in Folder.GetFiles()) { tmp = NextFile.Name; tn = ParentNode.Nodes.Add(tmp); tn.ImageIndex = 2; tn.SelectedImageIndex = 2; tn.Tag = "1"; tn.Tag = tn.Tag.ToString() + GetFullPath(tn); } } } else if ((SystemInfo.DBType == 1) || (SystemInfo.DBType == 2)) { try { dr = SystemInfo.db.GetDataReader("EXEC master..xp_dirtree '" + ParentPath + "',1," + Convert.ToByte(!OnlyPath).ToString()); while (dr.Read()) { tmp = dr[0].ToString().Trim(); tn = ParentNode.Nodes.Add(tmp); if (!OnlyPath && (dr[2].ToString() == "1")) { tn.ImageIndex = 2; tn.SelectedImageIndex = 2; tn.Tag = "1"; } else { tn.ImageIndex = 0; tn.SelectedImageIndex = 1; tn.Tag = "0"; tn.Nodes.Add(""); } tn.Tag = tn.Tag.ToString() + GetFullPath(tn); } ret = true; } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } } } return(ret); }
private void btnOk_Click(object sender, EventArgs e) { if (txtEmpNo.Text.Trim() == "" && cardGrid.DataSource == null) { txtEmpNo.Focus(); ShowErrorEnterCorrect(label2.Text); return; } if (cbbSun.SelectedIndex == -1) { cbbSun.Focus(); ShowErrorSelectCorrect(label3.Text); return; } if (cbbMon.SelectedIndex == -1) { cbbMon.Focus(); ShowErrorSelectCorrect(label5.Text); return; } if (cbbTue.SelectedIndex == -1) { cbbTue.Focus(); ShowErrorSelectCorrect(label6.Text); return; } if (cbbWed.SelectedIndex == -1) { cbbWed.Focus(); ShowErrorSelectCorrect(label7.Text); return; } string EmpSysID = txtEmpNo.Text; string SunID = cbbSun.Text; string MonID = cbbMon.Text; string TueID = cbbTue.Text; string WedID = cbbWed.Text; string ThuID = cbbThu.Text; string FriID = cbbFri.Text; string SatID = cbbSat.Text; if (cbbSun.SelectedIndex > 0) { SunID = ((TIDAndName)cbbSun.Items[cbbSun.SelectedIndex]).id; } if (cbbMon.SelectedIndex > 0) { MonID = ((TIDAndName)cbbMon.Items[cbbMon.SelectedIndex]).id; } if (cbbTue.SelectedIndex > 0) { TueID = ((TIDAndName)cbbTue.Items[cbbTue.SelectedIndex]).id; } if (cbbWed.SelectedIndex > 0) { WedID = ((TIDAndName)cbbWed.Items[cbbWed.SelectedIndex]).id; } if (cbbThu.SelectedIndex > 0) { ThuID = ((TIDAndName)cbbThu.Items[cbbThu.SelectedIndex]).id; } if (cbbFri.SelectedIndex > 0) { FriID = ((TIDAndName)cbbSun.Items[cbbFri.SelectedIndex]).id; } if (cbbSat.SelectedIndex > 0) { SatID = ((TIDAndName)cbbSun.Items[cbbSat.SelectedIndex]).id; } string StartDate = "NULL"; string EndDate = "NULL"; DateTime dt; if (DateTime.TryParse(txtStartDate.Text, out dt)) { StartDate = "'" + dt.ToString(SystemInfo.SQLDateFMT) + "'"; } if (DateTime.TryParse(txtEndDate.Text, out dt)) { EndDate = "'" + dt.ToString(SystemInfo.SQLDateFMT) + "'"; } List <string> macList = new List <string>(); for (int i = 0; i < macGrid.RowCount; i++) { if (Pub.ValueToBool(macGrid[0, i].EditedFormattedValue)) { macList.Add(macGrid[1, i].Value.ToString()); // macList.Add(macGrid[2, i].Value.ToString()); } } if (macList.Count == 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorSelectMacOprt", "")); return; } List <string> sql = new List <string>(); DataTableReader dr = null; bool IsError = false; string MacSN; try { for (int i = 0; i < macList.Count; i++) { MacSN = macList[i]; dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "503", MacSN, EmpSysID })); if (dr.Read()) { sql.Add(Pub.GetSQL(DBCode.DB_000300, new string[] { "505", MacSN, EmpSysID, SunID, MonID, TueID, WedID, ThuID, FriID, SatID, OprtInfo.OprtNo, StartDate, EndDate })); } else { sql.Add(Pub.GetSQL(DBCode.DB_000300, new string[] { "504", MacSN, EmpSysID, SunID, MonID, TueID, WedID, ThuID, FriID, SatID, OprtInfo.OprtNo, StartDate, EndDate })); } dr.Close(); if (cardGrid.DataSource != null) { DataTable dtGrid = (DataTable)cardGrid.DataSource; string EmpNo; for (int j = 0; j < dtGrid.Rows.Count; j++) { EmpNo = dtGrid.Rows[j]["EmpNo"].ToString(); if (EmpNo == EmpSysID) { continue; } dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "503", MacSN, EmpNo })); if (dr.Read()) { sql.Add(Pub.GetSQL(DBCode.DB_000300, new string[] { "505", MacSN, EmpNo, SunID, MonID, TueID, WedID, ThuID, FriID, SatID, OprtInfo.OprtNo, StartDate, EndDate })); } else { sql.Add(Pub.GetSQL(DBCode.DB_000300, new string[] { "504", MacSN, EmpNo, SunID, MonID, TueID, WedID, ThuID, FriID, SatID, OprtInfo.OprtNo, StartDate, EndDate })); } dr.Close(); } } } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return; } if (SystemInfo.db.ExecSQL(sql) != 0) { return; } SystemInfo.db.WriteSYLog(this.Text, CurrentOprt, sql); //Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); }
public void SeeTheModifiedTest() { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row _dt.Rows[1]["name"] = "mono changed"; reader.Read(); string value = reader[1].ToString(); Assert.Equal("mono changed", value); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void WriteCard() { if (!IsReadCard) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardReadFirst", "")); return; } string EmpNo = txtEmpNo.Text.Trim(); string EmpName = txtEmpName.Text.Trim(); int CardTypeID = ((TCardType)cbbCardType.Items[cbbCardType.SelectedIndex]).id; string CardSectorNo = txtCardSectorNo.Text.Trim(); CardSectorNo = Convert.ToUInt32(CardSectorNo).ToString("0000000000"); DateTime CardStartDate = new DateTime(); DateTime CardEndDate = new DateTime(); string CardPWD = txtCardPWD.Text.Trim(); string CardPWDA = txtCardPWDA.Text.Trim(); string DepartSysID = ""; if (txtDepartName.Tag != null) { DepartSysID = txtDepartName.Tag.ToString(); } if (EmpNo == "") { txtEmpNo.Focus(); ShowErrorEnterCorrect(label1.Text); return; } if (DepartSysID == "") { txtDepartName.Focus(); ShowErrorSelectCorrect(label4.Text); return; } if (!Pub.CheckTextMaxLength(label1.Text, EmpNo, txtEmpNo.MaxLength)) { txtEmpNo.Focus(); return; } if (!Pub.CheckTextMaxLength(label2.Text, EmpName, txtEmpName.MaxLength)) { txtEmpName.Focus(); return; } if (CardPWD == "") { CardPWD = "000000"; } if (!Pub.IsNumeric(CardPWD)) { txtCardPWD.Focus(); ShowErrorEnterCorrect(label16.Text); return; } if (!Pub.CheckTextMaxLength(label16.Text, CardPWD, txtCardPWD.MaxLength)) { txtCardPWD.Focus(); return; } CardPWD = Convert.ToInt32(CardPWD).ToString("000000"); if (CardPWD != CardPWDA) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorPasswordTwo", "")); return; } if ((txtCardStartDate.Text.Trim() == "") || (!DateTime.TryParse(txtCardStartDate.Text.Trim(), out CardStartDate))) { txtCardStartDate.Focus(); ShowErrorEnterCorrect(label13.Text); return; } if ((txtCardEndDate.Text.Trim() == "") || (!DateTime.TryParse(txtCardEndDate.Text.Trim(), out CardEndDate))) { txtCardEndDate.Focus(); ShowErrorEnterCorrect(label14.Text); return; } DataTableReader dr = null; bool IsOk = true; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "4", SysID, EmpNo })); if (dr.Read()) { txtEmpNo.Focus(); ShowErrorCannotRepeated(label1.Text); IsOk = false; } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (!IsOk) { return; } pubData.EmpNo = EmpNo; pubData.EmpName = EmpName; pubData.CardNo = CardSectorNo; pubData.CardTypeID = Convert.ToByte(CardTypeID); pubData.CardPWD = CardPWD; pubData.CardBeginDate = CardStartDate; pubData.CardEndDate = CardEndDate; pubData.IsCheckOrder = Convert.ToByte(CardCheckOrder); int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; string msg = "[" + EmpNo + "]" + EmpName + ": " + CardSectorNo + "/" + txtDepartName.Text; ContinuePub: Application.DoEvents(); CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!DeviceObject.objCPIC.GetCardData(ref CardNo10, ref CardNoH, ref CardNo8)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ReadCardError3", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ContinuePub; } } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinuePub; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinuePub; } } } cardRet = Pub.WriteCardInfo(pubData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinuePub; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ContinuePub; } } } ContinueData: Application.DoEvents(); if (!db.EmpCardModify(this.Text, oprt, CardSectorNo, CardTypeID, CardPWD, CardStartDate, CardEndDate, EmpNo, EmpName, DepartSysID)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", ""))) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardModifyFailed", "")); return; } else { goto ContinueData; } } IsChgOk = true; Pub.CardBuzzer(); db.WriteSYLog(this.Text, oprt, msg); db.UpdateEmpRegisterData(SysID, 10, CardPWD); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardModifySuccess", ""), MessageBoxIcon.Information); IsReadCard = false; ResetForm(); }
public void GetTest() { _dt.Columns.Add("nullint", typeof(int)); _dt.Rows[0]["nullint"] = 333; DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); int ordinal = reader.GetOrdinal("nullint"); // Get by name Assert.Equal(1, (int)reader["id"]); Assert.Equal(333, reader.GetInt32(ordinal)); Assert.Equal("Int32", reader.GetDataTypeName(ordinal)); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void btnReadCard_Click(object sender, EventArgs e) { IsReadCard = false; pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.TCardSFData(); CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return; } if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { ResetForm(); return; } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { ResetForm(); return; } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { ResetForm(); return; } DataTableReader dr = null; bool IsOk = false; string EmpNo = ""; string EmpName = ""; string CardPWD = ""; string DepartName = ""; string DepartID = ""; string CardStatusName = ""; string FaDate = ""; CardCheckOrder = false; SysID = ""; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardModifyNotNormal", "")); } else { SysID = dr["EmpSysID"].ToString(); EmpNo = dr["EmpNo"].ToString(); EmpName = dr["EmpName"].ToString(); CardPWD = dr["CardPWD"].ToString(); DepartName = dr["DepartName"].ToString(); DepartID = dr["DepartSysID"].ToString(); CardStatusName = dr["CardStatusName"].ToString(); FaDate = dr["FaDate"].ToString(); CardCheckOrder = Pub.ValueToBool(dr["CardCheckOrder"].ToString()); IsOk = true; } } else { Pub.ShowErrorMsg(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (!IsOk) { ResetForm(); return; } double BTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + BTMoney; txtEmpNo.Text = EmpNo; txtEmpName.Text = EmpName; txtCardPWD.Text = CardPWD; txtCardPWDA.Text = CardPWD; txtCardSectorNo.Text = pubData.CardNo; cbbCardType.SelectedIndex = -1; for (int i = 0; i < cbbCardType.Items.Count; i++) { if (((TCardType)cbbCardType.Items[i]).id == pubData.CardTypeID) { cbbCardType.SelectedIndex = i; break; } } txtCardStartDate.Text = pubData.CardBeginDate.ToShortDateString(); txtCardEndDate.Text = pubData.CardEndDate.ToShortDateString(); txtDepartName.Text = DepartName; txtDepartName.Tag = DepartID; txtCardStatusName.Text = CardStatusName; txtFaDate.Text = FaDate; txtSFCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); IsReadCard = true; Pub.CardBuzzer(); ResetForm(); txtEmpNo.Focus(); }
public void NoRowsTest() { _dt.Rows.Clear(); _dt.AcceptChanges(); DataTableReader reader = new DataTableReader(_dt); try { Assert.False(reader.Read()); Assert.False(reader.NextResult()); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
protected override void InitForm() { formCode = "SFReportDataOrder"; ReportFile = "SFReportDataOrder"; base.InitForm(); dtpStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0); dtpEnd.Value = DateTime.Now.Date.AddHours(23).AddMinutes(59).AddSeconds(59); dtpStart.CustomFormat = SystemInfo.DateTimeFormat; dtpEnd.CustomFormat = SystemInfo.DateTimeFormat; GetCardTypeList(); for (int i = 0; i < cardTypeList.Count; i++) { clbCardType.Items.Add(cardTypeList[i]); clbCardType.SetItemChecked(clbCardType.Items.Count - 1, false); } DataTableReader dr = null; TCommonType cType; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004005, new string[] { "2" })); while (dr.Read()) { cType = new TCommonType(dr["MealTypeSysID"].ToString(), dr["MealTypeID"].ToString(), dr["MealTypeName"].ToString(), true); clbMealType.Items.Add(cType); clbMealType.SetItemChecked(clbMealType.Items.Count - 1, false); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004004, new string[] { "0" })); while (dr.Read()) { clbMacSN.Items.Add(dr["MacSN"].ToString()); clbMacSN.SetItemChecked(clbMacSN.Items.Count - 1, false); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } clbMacSN.Items.Add("255"); clbMacSN.SetItemChecked(clbMacSN.Items.Count - 1, false); chkCardType_CheckedChanged(null, null); chkSFMealType_CheckedChanged(null, null); chkMacSN_CheckedChanged(null, null); btnAddress.Text = btnSelectEmp.Text; }
public void ReadAfterClosedTest() { Assert.Throws<InvalidOperationException>(() => { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); reader.Close(); reader.Read(); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
public Boolean Siguiente() { return(DR.Read()); }
public void InvalidIndexTest() { Assert.Throws<ArgumentOutOfRangeException>(() => { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); int i = (int)reader[90]; // kidding, ;-) i++; // to supress warning } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
private void btnOk_Click(object sender, EventArgs e) { string OldPass = Pub.GetOprtEncrypt(txtOld.Text.Trim()); string Pass = Pub.GetOprtEncrypt(txtNew.Text.Trim()); string PassA = Pub.GetOprtEncrypt(txtNewA.Text.Trim()); string OldPassA = ""; DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_000002, new string[] { "3", oprtNo })); if (!dr.Read()) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorOldPassword", "")); } else if (Pass != PassA) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorPasswordTwo", "")); } else { if (isHideOld) { db.ExecSQL(Pub.GetSQL(DBCode.DB_000002, new string[] { "201", Pass, oprtNo })); IsOk = true; } else { OldPassA = dr["OprtPWD"].ToString(); if (OldPass == "") { OldPass = Pub.GetOprtEncrypt("0"); } if (OldPassA == "") { OldPassA = Pub.GetOprtEncrypt("0"); } if (Pass == "") { Pass = Pub.GetOprtEncrypt("0"); } if (OldPass == OldPassA) { db.ExecSQL(Pub.GetSQL(DBCode.DB_000002, new string[] { "201", Pass, oprtNo })); IsOk = true; } else { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorOldPassword", "")); } } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk) { string msg = Pub.GetResText(formCode, "MsgPasswordSuccess", ""); db.WriteSYLog(this.Text, btnOk.Text, msg); Pub.MessageBoxShow(msg, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } }
public void AddAtPointTest() { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row reader.Read(); // second row DataRow r = _dt.NewRow(); r[0] = 0; r[1] = "same point"; _dt.Rows.InsertAt(r, 1); _dt.Rows.Add(new object[] { 4, "mono 4" }); // should not affect the counter Assert.Equal(2, (int)reader[0]); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void btnOk_Click(object sender, EventArgs e) { if (!CheckEmp()) { return; } if (dtpStart.Value > dtpEnd.Value) { dtpStart.Focus(); Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorStartTimeBegreater", "")); return; } if (cbbType.SelectedIndex == -1) { cbbType.Focus(); ShowErrorSelectCorrect(label7.Text); return; } string BillNo = txtNo.Text; string EmpSysID = txtEmpNo.Tag.ToString(); string TypeSysID = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).sysID; string Reason = txtReason.Text.Trim(); if (!Pub.CheckTextMaxLength(label8.Text, Reason, txtReason.MaxLength)) { return; } List <string> sql = new List <string>(); int days = (int)Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date); DataTableReader dr = null; bool IsError = false; bool IsExists = true; try { if (SysID == "") { while (IsExists) { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002008, new string[] { "6", BillNo })); if (!dr.Read()) { IsExists = false; } dr.Close(); if (IsExists) { BillNo = GetBillNo(); } } GetSql(days, EmpSysID, BillNo, TypeSysID, Reason, ref sql); if (cardGrid.DataSource != null) { DataTable dtGrid = (DataTable)cardGrid.DataSource; for (int i = 0; i < dtGrid.Rows.Count; i++) { if (dtGrid.Rows[i]["EmpSysID"].ToString() == EmpSysID) { continue; } GetSql(days, dtGrid.Rows[i]["EmpSysID"].ToString(), BillNo, TypeSysID, Reason, ref sql); } } } else { GetSql(days, EmpSysID, BillNo, TypeSysID, Reason, ref sql); } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return; } if (db.ExecSQL(sql) != 0) { return; } db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); }
public void DeleteFirstCurrentAndAcceptChangesTest() { Assert.Throws<InvalidOperationException>(() => { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row _dt.Rows[0].Delete(); // delete row, where reader points to _dt.AcceptChanges(); // accept the action Assert.Equal(2, (int)reader[0]); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }); }
private void LoadData() { cbbType.Items.Clear(); TCommonType ctype; DataTableReader dr = null; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002002, new string[] { "100" })); while (dr.Read()) { ctype = new TCommonType(dr["DayOffTypeSysID"].ToString(), dr["DayOffTypeNo"].ToString(), dr["DayOffTypeName"].ToString(), true); cbbType.Items.Add(ctype); } if (SysID == "") { if (cbbType.Items.Count > 0) { cbbType.SelectedIndex = 0; } txtNo.Text = GetBillNo(); } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002008, new string[] { "5", SysID })); if (dr.Read()) { txtNo.Text = dr["DayOffBillNo"].ToString(); txtEmpNo.Text = dr["EmpNo"].ToString(); txtEmpNo.Tag = dr["EmpSysID"].ToString(); txtEmpName.Text = dr["EmpName"].ToString(); txtDepart.Text = "[" + dr["DepartID"].ToString() + "]" + dr["DepartName"].ToString(); DateTime dt = new DateTime(); DateTime.TryParse(dr["DayoffStartDate"].ToString(), out dt); string[] tt = dr["DayoffStartTime"].ToString().Split(':'); dt = dt.AddHours(Convert.ToDouble(tt[0])).AddMinutes(Convert.ToDouble(tt[1])); dtpStart.Value = dt; DateTime.TryParse(dr["DayoffEndDate"].ToString(), out dt); tt = dr["DayoffEndTime"].ToString().Split(':'); dt = dt.AddHours(Convert.ToDouble(tt[0])).AddMinutes(Convert.ToDouble(tt[1])); dtpEnd.Value = dt; for (int i = 0; i < cbbType.Items.Count; i++) { if (((TCommonType)cbbType.Items[i]).sysID == dr["DayOffTypeSysID"].ToString()) { cbbType.SelectedIndex = i; break; } } txtReason.Text = dr["DayoffReason"].ToString(); } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } }
protected override void InitForm() { formCode = "SFAllowance"; switch (Application.CurrentCulture.LCID) { case 0x804: Report.Language = 0x804; break; case 0x404: case 0x0c04: case 0x1004: case 0x1404: Report.Language = 0x404; break; default: Report.Language = 0x0409; break; } Report1.Language = Report.Language; ReportFile = SystemInfo.ReportPath + "SFAllowance.grf"; ReportFile1 = SystemInfo.ReportPath + "SFAllowanceHistory.grf"; if ((ReportFile != "") && File.Exists(ReportFile)) { try { Report.Register(SystemInfo.ReportRegister); Report.LoadFromFile(ReportFile); Report.DetailGrid.Recordset.ConnectionString = SystemInfo.ConnStrReport; Report.DetailGrid.Recordset.QuerySQL = ""; Report.ShowProgressUI = false; ShowReportHeader(false); Report.FetchRecord -= new _IGridppReportEvents_FetchRecordEventHandler(ProductListFetchRecord); Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ProductListFetchRecord); dispView.Report = Report; //指示查询显示控件分批获取数据 dispView.BatchGetRecord = true; dispView.BatchWantRecords = 0; //指示查询显示控件显示出工具栏,并按分页方式显示数据 dispView.ShowToolbar = true; dispView.RowsPerPage = 0; dispView.Start(); } catch (Exception E) { Pub.ShowErrorMsg(E); } } if ((ReportFile1 != "") && File.Exists(ReportFile1)) { try { Report1.Register(SystemInfo.ReportRegister); Report1.LoadFromFile(ReportFile1); Report1.DetailGrid.Recordset.ConnectionString = SystemInfo.ConnStrReport; Report1.DetailGrid.Recordset.QuerySQL = ""; Report1.ShowProgressUI = false; ShowReportHeader(false); Report1.FetchRecord -= new _IGridppReportEvents_FetchRecordEventHandler(ProductListFetchRecord1); Report1.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ProductListFetchRecord1); dispView1.Report = Report1; //指示查询显示控件分批获取数据 dispView1.BatchGetRecord = true; dispView1.BatchWantRecords = 0; //指示查询显示控件显示出工具栏,并按分页方式显示数据 dispView1.ShowToolbar = true; dispView1.RowsPerPage = 0; dispView1.Start(); } catch (Exception E) { Pub.ShowErrorMsg(E); } } AddExtDropDownItem("ItemSetupDisplay", ItemSetupDisplay_Click); SetToolItemState("ItemTAG1", true); SetToolItemState("ItemTAGExt", true); SetToolItemState("ItemLine3", true); SetToolItemState("ItemSearch", true); AddExtDropDownItem("BatchAllowance", BatchAllowance_Click); IgnoreSelect = true; base.InitForm(); QuerySQL = Pub.GetSQL(DBCode.DB_004006, new string[] { "0", OprtInfo.DepartPower }); QuerySQL1 = Pub.GetSQL(DBCode.DB_004006, new string[] { "1", OprtInfo.DepartPower }); FindSQL = Pub.GetSQL(DBCode.DB_004006, new string[] { "2", OprtInfo.DepartPower }); FindSQL1 = Pub.GetSQL(DBCode.DB_004006, new string[] { "3", OprtInfo.DepartPower }); FindOrderBy = Pub.GetSQL(DBCode.DB_004006, new string[] { "4" }); if (SystemInfo.AllowanceCardType) { ImportFieldList = new string[] { "EmpNo", "CardType", "AllowanceFlag", "AllowanceWayName", "AllowanceAmount" } } ; else { ImportFieldList = new string[] { "EmpNo", "AllowanceFlag", "AllowanceWayName", "AllowanceAmount" } }; ImportShowCount = true; clbAllowanceStatus.Items.Clear(); clbAllowanceStatus1.Items.Clear(); TCommonType cType; DataTableReader dr = null; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004006, new string[] { "21" })); while (dr.Read()) { cType = new TCommonType(dr["AllowanceStatusID"].ToString(), dr["AllowanceStatusID"].ToString(), dr["AllowanceStatusName"].ToString(), true); clbAllowanceStatus.Items.Add(cType); clbAllowanceStatus1.Items.Add(cType); clbAllowanceStatus.SetItemChecked(clbAllowanceStatus.Items.Count - 1, false); clbAllowanceStatus1.SetItemChecked(clbAllowanceStatus1.Items.Count - 1, false); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } chkAllowanceStatus_CheckedChanged(null, null); chkAllowanceStatus1_CheckedChanged(null, null); dtpStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0); dtpEnd.Value = DateTime.Now.Date; dtpStart1.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0); dtpEnd1.Value = DateTime.Now.Date; }
public override bool ProcessImportData(DataRow row, List <string> sys, List <string> src, string DepartUpSysID, ref string ErrorMsg, ref double Sum) { bool ret = base.ProcessImportData(row, sys, src, DepartUpSysID, ref ErrorMsg, ref Sum); string EmpNo = ""; string CardTypeID = ""; string AllowanceFlag = ""; string AllowanceWay = ""; double AllowanceAmount = 0; for (int i = 0; i < sys.Count; i++) { switch (sys[i]) { case "EmpNo": EmpNo = row[src[i]].ToString(); break; case "CardType": CardTypeID = row[src[i]].ToString(); break; case "AllowanceFlag": AllowanceFlag = row[src[i]].ToString(); break; case "AllowanceWayName": AllowanceWay = row[src[i]].ToString(); break; case "AllowanceAmount": double.TryParse(row[src[i]].ToString(), out AllowanceAmount); break; } } if (EmpNo == "") { ErrorMsg = Pub.GetResText(formCode, "Error101", ""); return(false); } bool IsError = false; DataTableReader dr = null; string CardTypeSysID = ""; string EmpSysID = ""; List <string> sql = new List <string>(); sql.Clear(); bool AllowCount = false; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "2", EmpNo })); if (dr.Read()) { EmpSysID = dr["EmpSysID"].ToString(); } else { ErrorMsg = Pub.GetResText(formCode, "Error102", ""); return(false); } if (SystemInfo.AllowanceCardType) { if (!Pub.IsNumeric(CardTypeID)) { CardTypeID = "0"; } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "204", CardTypeID })); if (dr.Read()) { CardTypeSysID = dr["CardTypeSysID"].ToString(); } else { dr.Close(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "204", CardTypeID })); if (dr.Read()) { CardTypeSysID = dr["CardTypeSysID"].ToString(); } } if (CardTypeSysID == "") { ErrorMsg = Pub.GetResText(formCode, "Error103", ""); return(false); } } DateTime dFlag = new DateTime(); if (!DateTime.TryParse(AllowanceFlag, out dFlag)) { ErrorMsg = Pub.GetResText(formCode, "Error104", ""); return(false); } if (AllowanceAmount <= 0) { ErrorMsg = Pub.GetResText(formCode, "Error105", ""); return(false); } AllowanceWay = AllowanceWay.Substring(1, 1); int way = 0; if (!int.TryParse(AllowanceWay, out way)) { ErrorMsg = Pub.GetResText(formCode, "Error106", ""); return(false); } if ((way < 0) || (way > 2)) { ErrorMsg = Pub.GetResText(formCode, "Error106", ""); return(false); } DateTime dt = new DateTime(); byte retCheck = db.CheckAllowanceFlag(EmpSysID, dFlag, ref dt); if (retCheck == 1) { ErrorMsg = string.Format(Pub.GetResText(formCode, "Error107", ""), dt.ToShortDateString()); return(false); } else if (retCheck == 2) { ErrorMsg = string.Format(Pub.GetResText(formCode, "Error108", ""), dt.ToShortDateString()); return(false); } else if (retCheck == 3) { ErrorMsg = Pub.GetResText(formCode, "Error109", ""); return(false); } sql.Add(Pub.GetSQL(DBCode.DB_004006, new string[] { "7", EmpNo, dFlag.ToString(SystemInfo.SQLDateFMT), way.ToString(), AllowanceAmount.ToString() })); if (!GetSFAllowance(EmpSysID, dFlag, AllowanceAmount, way, ref sql, ref AllowCount)) { return(false); } if (SystemInfo.AllowanceCardType) { sql.Add(Pub.GetSQL(DBCode.DB_004006, new string[] { "14", CardTypeSysID, EmpSysID })); } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E, sql); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return(false); } if (db.ExecSQL(sql) != 0) { return(false); } db.WriteSYLog(this.Text, CurrentTool, sql); ret = true; if (AllowCount) { Sum = Sum + AllowanceAmount; } else { ret = false; } return(ret); }
public void MultipleDeleteTest() { _dt.Rows.Add(new object[] { 4, "mono 4" }); _dt.Rows.Add(new object[] { 5, "mono 5" }); _dt.Rows.Add(new object[] { 6, "mono 6" }); _dt.Rows.Add(new object[] { 7, "mono 7" }); _dt.Rows.Add(new object[] { 8, "mono 8" }); _dt.AcceptChanges(); DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row reader.Read(); reader.Read(); reader.Read(); reader.Read(); _dt.Rows[3].Delete(); _dt.Rows[1].Delete(); _dt.Rows[2].Delete(); _dt.Rows[0].Delete(); _dt.Rows[6].Delete(); _dt.AcceptChanges(); Assert.Equal(5, (int)reader[0]); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void btnOk_Click(object sender, EventArgs e) { int TypeID = 0; if (Pub.IsNumeric(txtNo.Text.Trim())) { TypeID = Convert.ToInt32(txtNo.Text.Trim()); } string TypeName = txtName.Text.Trim(); DataTableReader dr = null; bool IsOk = true; string sql = ""; if (!Pub.CheckTextMaxLength(Label2.Text, TypeName, txtName.MaxLength)) { return; } if ((TypeID < 100) || (TypeID > 109)) { txtNo.Focus(); ShowErrorEnterCorrect(Label1.Text); return; } if (TypeName == "") { txtName.Focus(); ShowErrorEnterCorrect(Label2.Text); return; } try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (SysID == "") { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004013, new string[] { "5", TypeID.ToString() })); if (dr.Read()) { if (txtNo.Enabled) { txtNo.Focus(); } ShowErrorCannotRepeated(Label1.Text); } else { sql = Pub.GetSQL(DBCode.DB_004013, new string[] { "1", TypeID.ToString(), TypeName }); db.ExecSQL(sql); } } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004013, new string[] { "6", SysID, TypeID.ToString() })); if (dr.Read()) { txtNo.Focus(); ShowErrorCannotRepeated(Label1.Text); } else { sql = Pub.GetSQL(DBCode.DB_004013, new string[] { "2", TypeID.ToString(), TypeName, SysID }); db.ExecSQL(sql); } } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (!IsOk) { return; } db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); }
public void IgnoreDeletedRowsDynamicTest() { DataTableReader reader = new DataTableReader(_dt); try { reader.Read(); // first row _dt.Rows[1].Delete(); reader.Read(); // it should be 3rd row string value = reader[0].ToString(); Assert.Equal("3", value); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void CheckAccount() { int DepositCount = 0; double DepositSum = 0; double DepositDiscount = 0; double GiftCount = 0; int RefundmentCount = 0; double RefundmentSum = 0; int EliminateCount = 0; double EliminateSum = 0; double BTSum = 0; double BTWSum = 0; double ZeroSum = 0; double NormalDZSum = 0; double NormalJZSum = 0; double InCardFee = 0; double ToCardFee = 0; double CardSum = 0; if (!CheckData(0, dtpCheck.Value, ref DepositCount, ref DepositSum, ref DepositDiscount, ref GiftCount, ref RefundmentCount, ref RefundmentSum, ref EliminateCount, ref EliminateSum, ref BTSum, ref ZeroSum, ref NormalDZSum, ref NormalJZSum, ref InCardFee, ref ToCardFee, ref CardSum, ref BTWSum)) { return; } int DepositCountX = 0; double DepositSumX = 0; double DepositDiscountX = 0; double GiftCountX = 0; int RefundmentCountX = 0; double RefundmentSumX = 0; int EliminateCountX = 0; double EliminateSumX = 0; double BTSumX = 0; double BTWSumX = 0; double ZeroSumX = 0; double NormalDZSumX = 0; double NormalJZSumX = 0; double InCardFeeX = 0; double ToCardFeeX = 0; double CardSumX = 0; if (!CheckData(1, dtpCheck.Value, ref DepositCountX, ref DepositSumX, ref DepositDiscountX, ref GiftCountX, ref RefundmentCountX, ref RefundmentSumX, ref EliminateCountX, ref EliminateSumX, ref BTSumX, ref ZeroSumX, ref NormalDZSumX, ref NormalJZSumX, ref InCardFeeX, ref ToCardFeeX, ref CardSumX, ref BTWSumX)) { return; } DataTableReader dr = null; double CardBalance = 0; double BTBalance = 0; double CardBTMoney = 0; double SFCardBalance = 0; double SFCardBalanceX = 0; double BTBalanceX = 0; bool IsError = false; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004007, new string[] { "4" })); if (dr.Read()) { double.TryParse(dr["CardBalance"].ToString(), out CardBalance); double.TryParse(dr["CardBTMoney"].ToString(), out CardBTMoney); } dr.Close(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004007, new string[] { "5" })); if (dr.Read()) { double.TryParse(dr[0].ToString(), out SFCardBalance); //double.TryParse(dr[0].ToString(), out BTBalance); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004007, new string[] { "10", dtpCheck.Value.AddDays(1).ToString(SystemInfo.SQLDateFMT) })); if (dr.Read()) { double.TryParse(dr[0].ToString(), out SFCardBalanceX); //double.TryParse(dr[0].ToString(), out BTBalanceX); } dr.Close(); } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return; } CardBalance = Math.Round(CardBalance, 2); SFCardBalance = Math.Round(SFCardBalance, 2); CardBTMoney = Math.Round(CardBTMoney, 2); SFCardBalanceX = Math.Round(SFCardBalanceX, 2); BTBalance = Math.Round(BTBalance, 2); BTBalanceX = Math.Round(BTBalanceX, 2); CardSum = Math.Round(CardSum, 2); CardSumX = Math.Round(CardSumX, 2); BTSumX = Math.Round(BTSumX, 2); BTSum = Math.Round(BTSum, 2); string msg = string.Format(Pub.GetResText(formCode, "Msg003", ""), (CardBalance + CardBTMoney).ToString(SystemInfo.CurrencySymbol + "0.00"), (SFCardBalance + BTBalance).ToString(SystemInfo.CurrencySymbol + "0.00"), (CardSumX).ToString(SystemInfo.CurrencySymbol + "0.00"), dtpCheck.Value.ToShortDateString(), (CardSum).ToString(SystemInfo.CurrencySymbol + "0.00")); string msgex = Pub.GetResText(formCode, "Msg004", ""); MessageBoxIcon icon = MessageBoxIcon.Question; bool IsEnforce = false; if ((CardBalance + CardBTMoney != CardSumX) || (CardBalance + CardBTMoney != SFCardBalance + BTBalance) || (CardSumX != SFCardBalance + BTBalance) || (CardSum != SFCardBalanceX + BTBalance)) { IsEnforce = true; msgex = Pub.GetResText(formCode, "Msg006", ""); icon = MessageBoxIcon.Exclamation; } if (Pub.MessageBoxShowQuestion(msg + "\r\n\r\n" + msgex, icon)) { return; } lblMsg.Text = Pub.GetResText(formCode, "Msg002", ""); Application.DoEvents(); if (!db.CreateDatabase(DBPath, AccDB)) { return; } if (!db.RestoreDatabase(AccDB, BakFile)) { db.DeleteDatabase(AccDB, true); return; } else { string fn = BakFile.Substring(BakFile.LastIndexOf("\\") + 1).ToLower(); bool IsOk = true; Database dbLang = new Database(GetConnStr(AccDB)); try { dbLang.Open(); if (IsOk && (fn == SystemInfo.DefaultDBBak.ToLower())) { IsOk = dbLang.UpdateDatabasesLang(); } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { dbLang.Close(); dbLang = null; } if (!IsOk) { db.DeleteDatabase(AccDB, true); return; } } string ConnStr = GetConnStr(AccDB); Database dbEx = new Database(ConnStr); try { dbEx.Open(); dr = dbEx.GetDataReader(Pub.GetSQL(DBCode.DB_000002, new string[] { "2" })); if (dr.Read()) { DateTime dt = Convert.ToDateTime(dr["DbDate"]); dbEx.UpdateDatabase(this.Text, dt); } dr.Close(); switch (SystemInfo.DBType) { case 1: case 2: dbEx.ExecSQL("ALTER TABLE RS_EmpFingerInfo DROP COLUMN FingerBackUpNo", true); dbEx.ExecSQL("ALTER TABLE RS_EmpFingerInfo ALTER COLUMN FingerTemplate image NULL", true); break; } if (IsEnforce) { CardSum = SFCardBalanceX; DepositCount = 0; DepositSum = 0; DepositDiscount = 0; GiftCount = 0; RefundmentCount = 0; RefundmentSum = 0; EliminateCount = 0; EliminateSum = 0; BTSum = 0; ZeroSum = 0; NormalDZSum = 0; NormalJZSum = 0; InCardFee = 0; ToCardFee = 0; BTWSum = 0; } switch (SystemInfo.DBType) { case 1: case 2: IsError = ExecCheck(dtpCheck.Value, CardSum, DepositCount, DepositSum, DepositDiscount, GiftCount, RefundmentCount, RefundmentSum, EliminateCount, EliminateSum, BTSum, ZeroSum, NormalDZSum, NormalJZSum, InCardFee, ToCardFee, AccName, AccDB, SystemInfo.AccDBName, SystemInfo.DatabaseName, IsEnforce, BTWSum); break; } if (IsError) { dbEx.Close(); db.DeleteDatabase(AccDB, true); } } catch (Exception E) { IsError = true; dbEx.Close(); db.DeleteDatabase(AccDB, true); Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; dbEx.Close(); } if (IsError) { return; } dataGrid[1, 0].Value = dtpCheck.Value.ToShortDateString(); dataGrid[1, 1].Value = CardSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 2].Value = DepositSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 3].Value = DepositDiscount.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 4].Value = GiftCount.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 5].Value = RefundmentSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 6].Value = EliminateSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 7].Value = BTSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 8].Value = ZeroSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 9].Value = NormalDZSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 10].Value = NormalJZSum.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 11].Value = InCardFee.ToString(SystemInfo.CurrencySymbol + "0.00"); dataGrid[1, 12].Value = ToCardFee.ToString(SystemInfo.CurrencySymbol + "0.00"); SystemInfo.AccIsForward = true; Pub.MessageBoxShow(Pub.GetResText(formCode, "Msg005", ""), MessageBoxIcon.Information); }