private void toolStripButtonGD_Click(object sender, EventArgs e) { int i, j; decimal dsum = 0, dsum1 = 0, dsum2 = 0;; //保存完毕 if (intCommID == 0) { MessageBox.Show("请选择要查询的商品", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (intKFID == 0) { MessageBox.Show("请选择要查询的库房", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } sqlConn.Open(); //sqlComm.CommandText = "SELECT 日期, 单据编号, 摘要, 入库数量, 入库单价, 入库金额, 出库数量, 出库金额, 退出数量, 退出金额, 退回数量, 退回金额, 借物数量, 借物金额, 库房结存数量, 库房结存金额, 销售金额, 毛利 FROM 商品库房历史账表 WHERE (商品ID = " + intCommID.ToString() + ") AND (BeActive = 1) AND (日期 >= CONVERT(DATETIME, '" + dateTimePickerS.Value.ToShortDateString() + " 00:00:00', 102)) AND (库房ID = " + intKFID.ToString() + ") ORDER BY 日期"; sqlComm.CommandText = "SELECT 单据编号, 数量, 单价, 实计金额, 毛利, '' AS 说明, 表单ID FROM 单据明细汇总视图 WHERE (BeActive = 1) AND (商品ID = " + intCommID.ToString() + ") AND (日期 >= CONVERT(DATETIME, '" + dateTimePickerS.Value.ToShortDateString() + " 00:00:00', 102)) AND (库房ID = " + intKFID.ToString() + ")"; switch (comboBoxDJLB.SelectedIndex) { case 1: sqlComm.CommandText += " AND 单据编号 LIKE N'%AKP%' "; break; case 2: sqlComm.CommandText += " AND 单据编号 LIKE N'%ADH%' "; break; case 3: sqlComm.CommandText += " AND 单据编号 LIKE N'%ATH%' "; break; case 4: sqlComm.CommandText += " AND 单据编号 LIKE N'%ATB%' "; break; case 5: sqlComm.CommandText += " AND 单据编号 LIKE N'%BKP%' "; break; case 6: sqlComm.CommandText += " AND 单据编号 LIKE N'%BCK%' "; break; case 7: sqlComm.CommandText += " AND 单据编号 LIKE N'%BTH%' "; break; case 8: sqlComm.CommandText += " AND 单据编号 LIKE N'%BTB%' "; break; case 9: sqlComm.CommandText += " AND 单据编号 LIKE N'%CCK%' AND 数量 > 0 "; break; case 10: sqlComm.CommandText += " AND 单据编号 LIKE N'%CCK%' AND 数量 < 0 "; break; } sqlComm.CommandText += " ORDER BY 日期"; if (dSet.Tables.Contains("商品表")) { dSet.Tables.Remove("商品表"); } sqlDA.Fill(dSet, "商品表"); dataGridViewDJMX.DataSource = dSet.Tables["商品表"]; dataGridViewDJMX.Columns[6].Visible = false; /* * for (i = 0; i < dSet.Tables["商品表"].Rows.Count; i++) * for (j = 3; j < dSet.Tables["商品表"].Columns.Count; j++) * { * if (dSet.Tables["商品表"].Rows[i][j].ToString() == "") * dSet.Tables["商品表"].Rows[i][j] = 0; * * } */ string stemp = ""; for (i = 0; i < dSet.Tables["商品表"].Rows.Count; i++) { if (dSet.Tables["商品表"].Rows[i][4].ToString() != "") { dsum += decimal.Parse(dSet.Tables["商品表"].Rows[i][4].ToString()); } if (dSet.Tables["商品表"].Rows[i][1].ToString() != "") { dsum1 += decimal.Parse(dSet.Tables["商品表"].Rows[i][1].ToString()); } if (dSet.Tables["商品表"].Rows[i][3].ToString() != "") { dsum2 += decimal.Parse(dSet.Tables["商品表"].Rows[i][3].ToString()); } stemp = dSet.Tables["商品表"].Rows[i][0].ToString().Substring(0, 3); switch (stemp) { case "AKP": dSet.Tables["商品表"].Rows[i][5] = "购进商品开票"; break; case "ADH": dSet.Tables["商品表"].Rows[i][5] = "购进商品入库"; break; case "ATH": dSet.Tables["商品表"].Rows[i][5] = "购进商品退出"; break; case "ATB": dSet.Tables["商品表"].Rows[i][5] = "购进商品退补差价"; break; case "BKP": dSet.Tables["商品表"].Rows[i][5] = "销售商品出库"; break; case "BCK": dSet.Tables["商品表"].Rows[i][5] = "销售商品出库校对"; break; case "BTH": dSet.Tables["商品表"].Rows[i][5] = "销售商品退回"; break; case "BTB": dSet.Tables["商品表"].Rows[i][5] = "销售商品退补差价"; break; case "CCK": dSet.Tables["商品表"].Rows[i][5] = "借物出库"; sqlComm.CommandText = "SELECT 出库金额, 冲抵单号ID, 单据编号 FROM 借物出库汇总表 WHERE (单据编号 = N'" + dSet.Tables["商品表"].Rows[i][0].ToString() + "')"; sqldr = sqlComm.ExecuteReader(); if (!sqldr.HasRows) { if (decimal.Parse(dSet.Tables["商品表"].Rows[i][1].ToString()) > 0) { dSet.Tables["商品表"].Rows[i][5] = "借物出库"; } else { dSet.Tables["商品表"].Rows[i][5] = "借物入库"; } sqldr.Close(); break; } sqldr.Read(); try { if (decimal.Parse(dSet.Tables["商品表"].Rows[i][1].ToString()) > 0) { if (sqldr.GetValue(1).ToString() == "-1") { dSet.Tables["商品表"].Rows[i][5] = "借物冲抵单(出库)"; } else { if (sqldr.GetValue(1).ToString() == "") { dSet.Tables["商品表"].Rows[i][5] = "借物出库单(未充抵)"; } else { dSet.Tables["商品表"].Rows[i][5] = "借物出库单(已充抵)"; } } } else { if (sqldr.GetValue(1).ToString() == "-1") { dSet.Tables["商品表"].Rows[i][5] = "借物冲抵单(入库)"; } else { if (sqldr.GetValue(1).ToString() == "") { dSet.Tables["商品表"].Rows[i][5] = "借物入库单(未充抵)"; } else { dSet.Tables["商品表"].Rows[i][5] = "借物入库单(已充抵)"; } } } } catch { if (decimal.Parse(dSet.Tables["商品表"].Rows[i][1].ToString()) > 0) { dSet.Tables["商品表"].Rows[i][5] = "借物出库"; } else { dSet.Tables["商品表"].Rows[i][5] = "借物入库"; } } sqldr.Close(); break; default: break; } } dataGridViewDJMX.Columns[1].DefaultCellStyle.Format = "f0"; dataGridViewDJMX.Columns[2].DefaultCellStyle.Format = "f2"; dataGridViewDJMX.Columns[3].DefaultCellStyle.Format = "f2"; dataGridViewDJMX.Columns[4].DefaultCellStyle.Format = "f2"; for (i = 0; i < dataGridViewDJMX.ColumnCount; i++) { dataGridViewDJMX.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } toolStripStatusLabelMXJLS.Text = dataGridViewDJMX.RowCount.ToString(); if (comboBoxDJLB.SelectedIndex == 0) { toolStripStatusLabelMXJLS.Text += " 毛利:" + dsum.ToString("f2"); } else { toolStripStatusLabelMXJLS.Text += " 数量:" + dsum1.ToString("f0") + " 金额:" + dsum2.ToString("f2"); } sqlConn.Close(); }
public static void ExecuteCommand(string aCommand, Socket aSocket) { try { if (aCommand != null) { string[] command = aCommand.Split(' '); if (command[0] == "/help") { if (aSocket == null) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(" Ingame notice: Type 1 space then message."); Console.WriteLine(" //clear"); Console.WriteLine(" //repairitems"); Console.WriteLine(" //respawn_unique"); Console.WriteLine(" //event"); Console.WriteLine(" //shutdown"); Console.WriteLine(" //manager"); Console.ForegroundColor = ConsoleColor.Yellow; } else { sendSocket(aSocket, "Ingame notice: Type 1 space then message." + Environment.NewLine); sendSocket(aSocket, " //clear = cleanup unused memory" + Environment.NewLine); sendSocket(aSocket, " //repairitems" + Environment.NewLine); sendSocket(aSocket, " //respawn_unique" + Environment.NewLine); sendSocket(aSocket, " //event" + Environment.NewLine); sendSocket(aSocket, " //shutdown" + Environment.NewLine); } } else if (command[0] == "//clear") { System.GC.Collect(); GC.Collect(0, GCCollectionMode.Forced); sendSocket(aSocket, "done memory cleanup" + Environment.NewLine); } else if (command[0] == "//shutdown") { byte waitTime = 5; if (command.Length > 1) { waitTime = System.Convert.ToByte(command[1]); } if (aSocket != null) { aSocket.Send(Encoding.ASCII.GetBytes("SHUTDOWN_START" + Environment.NewLine)); } lock (Systems.clients) { Console.WriteLine("{0}stopping server and sending notice to clients ...", DarkEmu_GameServer.Global.Product.Prefix); sendSocket(aSocket, "SHUTDOWN: stopping server and sending notice to clients ..." + Environment.NewLine); net.ServerCheck(true); net.Stop(); // disable any new connection try { Systems.SendAll(Packet.ChatPacket(7, 0, "The server is stopping, your information will be saved.", "")); Systems.SendAll(Packet.StartingLeaveGame(waitTime, 0)); } catch { } Thread.Sleep(waitTime); Console.WriteLine("@SHUTDOWN: logoff clients ..."); sendSocket(aSocket, "@SHUTDOWN: logoff clients ..." + Environment.NewLine); while (Systems.clients.Count > 0) { try { try { Systems.clients[0].Send(Packet.EndLeaveGame()); } catch { } //Ignore new character case (used for disconnect kick). Systems c = new Systems(); Systems.clients[0].Disconnect("normal"); } catch { } } } sendSocket(aSocket, "SHUTDOWN_END" + Environment.NewLine); cancelServer = true; Systems.UpdateServerInfo(0); //Environment.Exit(0); } else if (command[0] == "//repairitems") { int fixeditem = 0; Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items"); using (System.Data.SqlClient.SqlDataReader reader = ms.Read()) { while (reader.Read()) { short amount = reader.GetInt16(7); if (amount < 1) { fixeditem++; amount = 1; Systems.MsSQL.InsertData("UPDATE char_items SET quantity='" + amount + "' WHERE itemnumber='" + "item" + reader.GetByte(5) + "' AND owner='" + reader.GetInt32(3) + "' AND itemid='" + reader.GetInt32(2) + "'"); } } } Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("@Gameserver: Items Repaired: {0}", fixeditem); Console.ForegroundColor = ConsoleColor.Yellow; sendSocket(aSocket, String.Format("@Gameserver: Items Repaired: {0}", fixeditem) + Environment.NewLine); } else if (command[0] == "//respawn_unique") { DarkEmu_GameServer.GlobalUnique.StartTGUnique(6000 * 10, 6000 * 10); DarkEmu_GameServer.GlobalUnique.StartUriUnique(7000 * 10, 7000 * 10); DarkEmu_GameServer.GlobalUnique.StartIsyUnique(8000 * 10, 8000 * 10); DarkEmu_GameServer.GlobalUnique.StartLordUnique(9000 * 10, 9000 * 10); DarkEmu_GameServer.GlobalUnique.StartDemonUnique(10000 * 10, 10000 * 10); DarkEmu_GameServer.GlobalUnique.StartCerbUnique(11000 * 10, 11000 * 10); DarkEmu_GameServer.GlobalUnique.StartIvyUnique(11000 * 10, 11000 * 10); //Game.GlobalUnique.StartRoc(11000 * 10, 11000 * 10); DarkEmu_GameServer.GlobalUnique.StartMedusa(11000 * 10, 11000 * 10); DarkEmu_GameServer.GlobalUnique.StartNeith(11000 * 10, 11000 * 10); //Game.GlobalUnique.StartSphinx(11000 * 10, 11000 * 10); DarkEmu_GameServer.GlobalUnique.StartIsis(11000 * 10, 11000 * 10); sendSocket(aSocket, "done respawn" + Environment.NewLine); } else if (command[0] == "//event") { EventMain eventnew = new EventMain(System.IO.Directory.GetCurrentDirectory() + "/data/event.txt"); eventnew.Start(); sendSocket(aSocket, "Event Started" + Environment.NewLine); } else if (command[0] == "") { string information = aCommand; DarkEmu_GameServer.Systems c = new DarkEmu_GameServer.Systems(); DarkEmu_GameServer.Systems.SendAll(c.sendnoticecon(7, 0, information, "")); Console.WriteLine("Notice: " + information); sendSocket(aSocket, "Sent Notice: " + information + Environment.NewLine); } } } catch (Exception ex) { Console.WriteLine("Program.Main {0}", ex); } }
public TList_AliquotaSimples Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { TList_AliquotaSimples lista = new TList_AliquotaSimples(); bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); try { while (reader.Read()) { TRegistro_AliquotaSimples reg = new TRegistro_AliquotaSimples(); if (!reader.IsDBNull(reader.GetOrdinal("ID_Tabela"))) { reg.Id_tabela = reader.GetDecimal(reader.GetOrdinal("ID_Tabela")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_Aliquota"))) { reg.Id_aliquota = reader.GetDecimal(reader.GetOrdinal("ID_Aliquota")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Aliquota"))) { reg.Ds_aliquota = reader.GetString(reader.GetOrdinal("DS_Aliquota")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_Aliquota"))) { reg.Pc_aliquota = reader.GetDecimal(reader.GetOrdinal("PC_Aliquota")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_IRPJ"))) { reg.Pc_irpj = reader.GetDecimal(reader.GetOrdinal("PC_IRPJ")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_CSLL"))) { reg.Pc_csll = reader.GetDecimal(reader.GetOrdinal("PC_CSLL")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_Cofins"))) { reg.Pc_cofins = reader.GetDecimal(reader.GetOrdinal("PC_Cofins")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_PIS"))) { reg.Pc_pis = reader.GetDecimal(reader.GetOrdinal("PC_PIS")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_CPP"))) { reg.Pc_cpp = reader.GetDecimal(reader.GetOrdinal("PC_CPP")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_ICMS"))) { reg.Pc_icms = reader.GetDecimal(reader.GetOrdinal("PC_ICMS")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_IPI"))) { reg.Pc_ipi = reader.GetDecimal(reader.GetOrdinal("PC_IPI")); } if (!reader.IsDBNull(reader.GetOrdinal("PC_ISS"))) { reg.Pc_iss = reader.GetDecimal(reader.GetOrdinal("PC_ISS")); } lista.Add(reg); } return(lista); } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } }
public static void ClientService() { // try { ClientClass C = CC; NetworkStream ns = C.Client.GetStream(); bool LoggedIn = false; //StreamReader sr = new StreamReader( while (true) { Thread.Sleep(5); //:D //Console.Write(400); if (C.Client.Available >= 3) { byte[] buffer = new byte[C.Client.Available]; //ns.Read(buffer,0,buffer.Length); C.Client.Client.Receive(buffer); Base64Decoder B64 = new Base64Decoder(E.GetChars(buffer)); buffer = B64.GetDecoded(); string data = E.GetString(buffer); //Console.WriteLine(data); bool o = C.LoggedIn; if (C.Decode(data, out data, EncodingType.CSEnc)) { } else { //Limited options for the user to have... string[] la = new string[1]; if (data.Contains("|")) { la = data.Replace("||", Convert.ToChar(2).ToString()).Split('|'); for (int I = 0; I < la.Length; I++) { la[I] = la[I].Replace(Convert.ToChar(2).ToString(), "|"); } } else { la[0] = data; } if (o) { //Full capability... if (data.StartsWith("cht|") && !(C.Permission.Contains("CB"))) { //Send chat to the other clients...} foreach (ClientClass a in Clients) { a.SendPacket("cht|(" + DateTime.Now.Hour + DateTime.Now.Minute + ") " + C.name + "[" + C.Permission + "]: " + la[1], EncodingType.CSEnc); } } else if (data.StartsWith("file|") && (C.Permission.Contains("DEV"))) { //since we have perm, lets continue... if (data.StartsWith("file|w|")) { } //Write the file } else if (data.StartsWith("sqlq|")) { //sql query + return string[] sp = data.Split('|'); string CRC = sp[1]; string dar = ""; string y = sp[2]; if (C.CheckPermissions(ref y, true, true)) { //Console.WriteLine("TEST!"); try { Com.CommandText = y; System.Data.SqlClient.SqlDataReader mcm = Com.ExecuteReader(); while (mcm.Read()) { string ao = ""; for (int I = 0; I < mcm.FieldCount; I++) { string d = Convert.ToChar(2) + ""; if (I == mcm.FieldCount - 1) { d = ""; } if (mcm.IsDBNull(I)) { ao += d; } else { ao += Convert.ToString(mcm.GetValue(I)) + d; } } dar += ao + Convert.ToChar(1); } mcm.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } try { dar = dar.Remove(dar.Length - 1, 1); } catch { } //Console.WriteLine(dar); C.Client.SendBufferSize = ("sqlq|" + CRC + "|" + dar).Length; C.SendPacket("sqlq|" + CRC + "|" + dar, EncodingType.CSEnc); } else { C.SendPacket("sqlq|" + CRC + "|", EncodingType.CSEnc); C.SendPacket("noper", EncodingType.CSEnc); } } else if (data.StartsWith("sqlc|")) { //Sql query string[] sp = data.Split('|'); string y1 = sp[1]; if (C.CheckPermissions(ref sp[1], true, true)) { //Com.CommandText = y1; //Com.ExecuteNonQuery(); } else { C.SendPacket("noper", EncodingType.CSEnc); } Com.CommandText = y1; Com.ExecuteNonQuery(); } else if (data.StartsWith("logout|")) //separators...| { C.name = "anon"; C.LoggedIn = false; LoggedIn = false; } else if (data.StartsWith("DBNames|")) //Client is asking for the set DB names... { C.SendPacket("DBNames|" + GetSetting("SQLAccDB") + "|" + GetSetting("SQLGameDB"), EncodingType.CSEnc); } else { if (C.CheckPermissions(ref data, false, false)) { } else { C.SendPacket("noper", EncodingType.CSEnc); } } } if (data.StartsWith("login|")) //separators...| { try { string[] l = data.Split('|'); Com.CommandText = "SELECT * FROM [" + GetSetting("SQLAccDB") + "].[dbo].[account_login] WHERE [name] = '" + l[1] + "'"; System.Data.SqlClient.SqlDataReader dr = Com.ExecuteReader(); bool UserPassed = false, ISGM = false; if (dr.Read()) { if (dr.GetString(2) == l[2]) { //Password has passed also. UserPassed = true; } } dr.Close(); Com.CommandText = "SELECT * FROM [" + GetSetting("SQLGameDB") + "].[dbo].[account] WHERE [act_name] = '" + l[1] + "'"; dr = Com.ExecuteReader(); if (dr.Read()) { if (Convert.ToString(dr.GetValue(2)) == "99") { ISGM = true; } } dr.Close(); C.GetPermissions(l[1], ISGM); //Console.ForegroundColor = ConsoleColor.Red; //Console.WriteLine(C.Permission); if (UserPassed && !(C.Permission.StartsWith("X"))) //People that still have "X" will not pass!!! { C.SendPacket("login|true", EncodingType.CSEnc); C.LoggedIn = true; LoggedIn = true; //this doesn't work? wtf..lol..? C.name = l[1]; Console.WriteLine(C.name + " Logged in. IP: " + C.Client.Client.RemoteEndPoint.ToString() + " Perm: " + C.Permission); LG("Logged_In", DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + " - User[" + C.name + "] Logs in. IP: " + C.Client.Client.RemoteEndPoint.ToString()); } else { C.SendPacket("login|false", EncodingType.CSEnc); Console.WriteLine(C.name + " Failed to log in with '" + l[1] + "' as a username. IP: " + C.Client.Client.RemoteEndPoint.ToString()); LG("Logged_Fail", DateTime.Now.Date + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + " - User[" + l[1] + "] Unable to log in. IP: " + C.Client.Client.RemoteEndPoint.ToString()); } } catch (Exception e) { Console.WriteLine(e.Message); } } } } } } catch { } }
public TList_ProdutoDerivado SelectProdDeriv(string vNr_contrato, string vCd_empresa, string vTp_pesagem, string vId_ticket) { StringBuilder sql = new StringBuilder(); sql.AppendLine("select a.cd_produto, b.ds_produto, "); sql.AppendLine("qtd_embalagem = isnull((select sum(isnull(x.qtd_embalagem, 0)) "); sql.AppendLine(" from tb_bal_produtoderivado x "); sql.AppendLine(" where x.cd_produto = a.cd_produto "); sql.AppendLine(" and x.cd_empresa = '"+ vCd_empresa.Trim() + "' "); sql.AppendLine(" and x.tp_pesagem = '"+ vTp_pesagem.Trim() + "' "); sql.AppendLine(" and x.id_ticket = "+ vId_ticket + "), 0) "); sql.AppendLine("from tb_gro_contrato_x_pedidoitem a "); sql.AppendLine("inner join tb_est_produto b "); sql.AppendLine("on a.cd_produto = b.cd_produto "); sql.AppendLine("where a.nr_contrato = " + vNr_contrato); sql.AppendLine("and not exists(select 1 from tb_bal_psgraos x "); sql.AppendLine(" where x.nr_contrato = a.nr_contrato "); sql.AppendLine(" and x.nr_pedidounico = a.nr_pedido "); sql.AppendLine(" and x.cd_produto = a.cd_produto "); sql.AppendLine(" and x.cd_empresa = '"+ vCd_empresa.Trim() + "' "); sql.AppendLine(" and x.tp_pesagem = '"+ vTp_pesagem.Trim() + "' "); sql.AppendLine(" and x.id_ticket = "+ vId_ticket + ")"); bool st_transacao = false; TList_ProdutoDerivado lista = new TList_ProdutoDerivado(); if (Banco_Dados == null) { st_transacao = this.CriarBanco_Dados(false); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(sql.ToString()); try { while (reader.Read()) { TRegistro_ProdutoDerivado reg = new TRegistro_ProdutoDerivado(); if (!(reader.IsDBNull(reader.GetOrdinal("CD_Produto")))) { reg.Cd_produto = reader.GetString(reader.GetOrdinal("CD_Produto")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Produto"))) { reg.Ds_produto = reader.GetString(reader.GetOrdinal("DS_Produto")); } if (!reader.IsDBNull(reader.GetOrdinal("QTD_Embalagem"))) { reg.Qtd_embalagem = reader.GetDecimal(reader.GetOrdinal("QTD_Embalagem")); } lista.Add(reg); } return(lista); } finally { reader.Close(); reader.Dispose(); if (st_transacao) { this.deletarBanco_Dados(); } } }
public TList_GuardaVolume Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo) { TList_GuardaVolume lista = new TList_GuardaVolume(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo)); while (reader.Read()) { TRegistro_GuardaVolume reg = new TRegistro_GuardaVolume(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("Nm_empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("Nm_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("Id_guardavol"))) { reg.Id_guardavol = reader.GetDecimal(reader.GetOrdinal("Id_guardavol")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_Mudanca"))) { reg.Id_mudanca = reader.GetDecimal(reader.GetOrdinal("ID_Mudanca")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Cidade_orig"))) { reg.Ds_cidade_orig = reader.GetString(reader.GetOrdinal("DS_Cidade_orig")); } if (!reader.IsDBNull(reader.GetOrdinal("ufOrig"))) { reg.Uf_orig = reader.GetString(reader.GetOrdinal("ufOrig")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Cidade_dest"))) { reg.Ds_cidade_dest = reader.GetString(reader.GetOrdinal("DS_Cidade_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("ufDest"))) { reg.Uf_dest = reader.GetString(reader.GetOrdinal("ufDest")); } if (!reader.IsDBNull(reader.GetOrdinal("Cd_Motorista"))) { reg.Cd_motorista = reader.GetString(reader.GetOrdinal("Cd_Motorista")); } if (!reader.IsDBNull(reader.GetOrdinal("NM_Motorista"))) { reg.Nm_motorista = reader.GetString(reader.GetOrdinal("NM_Motorista")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Veiculo"))) { reg.Ds_veiculo = reader.GetString(reader.GetOrdinal("DS_Veiculo")); } if (!reader.IsDBNull(reader.GetOrdinal("Placa"))) { reg.Placa = reader.GetString(reader.GetOrdinal("Placa")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Clifor"))) { reg.Cd_clifor = reader.GetString(reader.GetOrdinal("CD_Clifor")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_clifor"))) { reg.Nm_clifor = reader.GetString(reader.GetOrdinal("nm_clifor")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_endereco"))) { reg.Cd_endereco = reader.GetString(reader.GetOrdinal("cd_endereco")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_endereco"))) { reg.Ds_endereco = reader.GetString(reader.GetOrdinal("ds_endereco")); } if (!reader.IsDBNull(reader.GetOrdinal("NR_GuardaVol"))) { reg.NR_GuardaVol = reader.GetString(reader.GetOrdinal("NR_GuardaVol")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_Registro"))) { reg.Dt_registro = reader.GetDateTime(reader.GetOrdinal("DT_Registro")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_PrevRetirada"))) { reg.Dt_prevretirada = reader.GetDateTime(reader.GetOrdinal("DT_PrevRetirada")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao"))) { reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_Registro"))) { reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public List <Tipo75> Select(string Cd_empresa, DateTime Dt_ini, DateTime Dt_fin, DateTime?Dt_inventario) { List <Tipo75> retorno = new List <Tipo75>(); bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } System.Collections.Hashtable hs = new System.Collections.Hashtable(4); hs.Add("@P_CD_EMPRESA", Cd_empresa); hs.Add("@P_DT_INI", Dt_ini); hs.Add("@P_DT_FIN", DateTime.Parse(Dt_fin.ToString("dd/MM/yyyy") + " 23:59:59")); hs.Add("@P_DT_INVENTARIO", Dt_inventario); System.Data.SqlClient.SqlDataReader reader = this.executarProcReader("DBO.STP_FIS_REG75", hs); try { while (reader.Read()) { Tipo75 reg = new Tipo75(); if (!reader.IsDBNull(reader.GetOrdinal("cd_produto"))) { reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_produto"))) { reg.Ds_produto = reader.GetString(reader.GetOrdinal("ds_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("ncm"))) { reg.Ncm = reader.GetString(reader.GetOrdinal("ncm")); } if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade"))) { reg.Sigla = reader.GetString(reader.GetOrdinal("sigla_unidade")); } if (!reader.IsDBNull(reader.GetOrdinal("pc_aliquota_ipi"))) { reg.Pc_aliquota_ipi = reader.GetDecimal(reader.GetOrdinal("pc_aliquota_ipi")); } if (!reader.IsDBNull(reader.GetOrdinal("pc_aliquota_icms"))) { reg.Pc_aliquota_icms = reader.GetDecimal(reader.GetOrdinal("pc_aliquota_icms")); } if (!reader.IsDBNull(reader.GetOrdinal("pc_reducaobasecalc"))) { reg.Pc_reducao_basecalcicms = reader.GetDecimal(reader.GetOrdinal("pc_reducaobasecalc")); } if (!reader.IsDBNull(reader.GetOrdinal("vl_basecalcsubsttrib"))) { reg.Base_calc_icms_substtrib = reader.GetDecimal(reader.GetOrdinal("vl_basecalcsubsttrib")); } retorno.Add(reg); } return(retorno); } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } }
private void PreencheCampos() { string stringSelect = @"select Nome,Apelido, " + "Endereco,Bairro,CEP,Cidade,Filiacao_Pai,Filiacao_Mae,Nascimento,Naturalidade,Nacionalidade,Escolaridade," + "CPF,RG,RG_Orgao,RG_Data_Exped,PIS,NIT, " + "Titulo,Titulo_Zona,Titulo_Secao,CEI,Estado_Civil,Telefone,email,Sexo, " + "CTPS,RGP,RGP_Registro,RGP_emissor,Profissao,Categoria, " + "AreaAtuacao,Relacao_Trabalho,Embarcacao_Utiliza,Embarcacao_Nome,Embarcacao_Prop,Embarcacao_Tipo, " + "Embarcacao_Tamanho,Embarcacao_PRopulsao,Embarcacao_capitania,RGP_MPA,Arte_Principal,Arte_Dono, " + "Arte_Esepcies,Arte_locais_venda,Arte_comercializado,Trabalho_dias,Trabalho_duracao,Trabalho_producao, " + "Trabalho_valor_venda,Trabalho_consumido, " + "Dependentes,Filhos_Escola,Seguro_Defeso,Bolsa_Familia,Tipo_Resid,possui_Agua_Encanada, " + "possui_Energia,possui_Telefone,possui_esgoto,possui_computador,pessoas_Resid, pessoas_Menores, " + "pessoas_aposentados,renda_mensal,outra_atividade,renda_outra,valor_Seguro_desemprego,valor_bolsa_familia, " + "total_renda_familiar ,tempo_associado,mensalidade_em_dias,valor_mensalidade ,motivo_inadimp, satisfeito,opniao,ID_Colonia, FotoDataURI " + "from Tbl_Associados where ID_Associado = " + lblIDAssoc.Text; OperacaoBanco operacao = new OperacaoBanco(); System.Data.SqlClient.SqlDataReader rcrdset = operacao.Select(stringSelect); while (rcrdset.Read()) { txtNome.Text = Convert.ToString(rcrdset[0]); txtApelido.Text = Convert.ToString(rcrdset[1]); txtEndereco.Text = Convert.ToString(rcrdset[2]); txtBairro.Text = Convert.ToString(rcrdset[3]); txtCEP.Text = Convert.ToString(rcrdset[4]); txtMunicipio.Text = Convert.ToString(rcrdset[5]); txtPai.Text = Convert.ToString(rcrdset[6]); txtMae.Text = Convert.ToString(rcrdset[7]); txtNascimento.Text = Convert.ToString(rcrdset[8]); txtNaturalidade.Text = Convert.ToString(rcrdset[9]); txtNacionalidade.Text = Convert.ToString(rcrdset[10]); txtEscolaridade.Text = Convert.ToString(rcrdset[11]); txtCPF.Text = Convert.ToString(rcrdset[12]); txtRG.Text = Convert.ToString(rcrdset[13]); txtEmissor.Text = Convert.ToString(rcrdset[14]); txtEmissao.Text = Convert.ToString(rcrdset[15]); txtPIS.Text = Convert.ToString(rcrdset[16]); txtNIT.Text = Convert.ToString(rcrdset[17]); txtTitulo.Text = Convert.ToString(rcrdset[18]); //txtZOna.Text = Convert.ToString(rcrdset[19]); //txtSecao.Text = Convert.ToString(rcrdset[20]); txtCEI.Text = Convert.ToString(rcrdset[21]); txtEstCivil.Text = Convert.ToString(rcrdset[22]); txtTelefone.Text = Convert.ToString(rcrdset[23]); txtemail.Text = Convert.ToString(rcrdset[24]); txtsexo.Text = Convert.ToString(rcrdset[25]); txtCTPS.Text = Convert.ToString(rcrdset[26]); txtRGPAtual.Text = Convert.ToString(rcrdset[27]); txtRGPRegistro.Text = Convert.ToString(rcrdset[28]); txtRGPEmissor.Text = Convert.ToString(rcrdset[29]); txtProf.Text = Convert.ToString(rcrdset[30]); txtCat.Text = Convert.ToString(rcrdset[31]); txtAtuacao.Text = Convert.ToString(rcrdset[32]); txtRelacao.Text = Convert.ToString(rcrdset[33]); txtutilizaEmbarca.Text = Convert.ToString(rcrdset[34]); txtNomeEmbarca.Text = Convert.ToString(rcrdset[35]); txtPropietario.Text = Convert.ToString(rcrdset[36]); txtTipo.Text = Convert.ToString(rcrdset[37]); txtTamanho.Text = Convert.ToString(rcrdset[38]); txtProp.Text = Convert.ToString(rcrdset[39]); txtCapitania.Text = Convert.ToString(rcrdset[40]); txtRGPMPA.Text = Convert.ToString(rcrdset[41]); txtArtes.Text = Convert.ToString(rcrdset[42]); txtDonoArtes.Text = Convert.ToString(rcrdset[43]); txtPRincipais.Text = Convert.ToString(rcrdset[44]); txtLocais.Text = Convert.ToString(rcrdset[45]); txtComoComerc.Text = Convert.ToString(rcrdset[46]); txtDiasTrab.Text = Convert.ToString(rcrdset[47]); txtDuracao.Text = Convert.ToString(rcrdset[48]); txtProdMedia.Text = Convert.ToString(rcrdset[49]); txtVEndaPRod.Text = Convert.ToString(rcrdset[50]); txtQuantConsumido.Text = Convert.ToString(rcrdset[51]); txtDependentes.Text = Convert.ToString(rcrdset[52]); txtfilhosescola.Text = Convert.ToString(rcrdset[53]); txtsegdefeso.Text = Convert.ToString(rcrdset[54]); txtBolsafamilia.Text = Convert.ToString(rcrdset[55]); txtCasaPropia.Text = Convert.ToString(rcrdset[56]); txtAguaEncan.Text = Convert.ToString(rcrdset[57]); txtpossuiEnergia.Text = Convert.ToString(rcrdset[58]); txtpossuiTelefone.Text = Convert.ToString(rcrdset[59]); txtpossuiEsgoto.Text = Convert.ToString(rcrdset[60]); txtPossuiCOmput.Text = Convert.ToString(rcrdset[61]); txtQuantPessoas.Text = Convert.ToString(rcrdset[62]); txtQuantMenores.Text = Convert.ToString(rcrdset[63]); txtAposentado.Text = Convert.ToString(rcrdset[64]); txtRendaAtividade.Text = Convert.ToString(rcrdset[65]); TxtExerceOutra.Text = Convert.ToString(rcrdset[66]); txtRendaOutra.Text = Convert.ToString(rcrdset[67]); txtVAlorDefeso.Text = Convert.ToString(rcrdset[68]); txtValorBolsaFam.Text = Convert.ToString(rcrdset[69]); txtRendaFamil.Text = Convert.ToString(rcrdset[70]); txtTempoAssoc.Text = Convert.ToString(rcrdset[71]); txtEmdias.Text = Convert.ToString(rcrdset[72]); txtValorMens.Text = Convert.ToString(rcrdset[73]); txtMotivoInadimp.Text = Convert.ToString(rcrdset[74]); txtSatisfeito.Text = Convert.ToString(rcrdset[75]); txtOpniao.Text = Convert.ToString(rcrdset[76]); string ScriptFoto = "<script language=javascript>document.getElementById('results').innerHTML = '<img src=\"" + Convert.ToString(rcrdset[78]) + "\"/>';" + "document.getElementById('Hidden1').value = \"" + Convert.ToString(rcrdset[78]) + "\"; </script>"; ClientScript.RegisterStartupScript(this.GetType(), "montafoto", ScriptFoto); } ConexaoBancoSQL.fecharConexao(); txtNome.Focus(); }
public TList_CTB_CFGCompFixacao Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { TList_CTB_CFGCompFixacao lista = new TList_CTB_CFGCompFixacao(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); while (reader.Read()) { TRegistro_CTB_CFGCompFixacao reg = new TRegistro_CTB_CFGCompFixacao(); if (!reader.IsDBNull(reader.GetOrdinal("ID_CFGCTB"))) { reg.Id_cfgctb = reader.GetDecimal(reader.GetOrdinal("ID_CFGCTB")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("CD_Empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("NM_Empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("NM_Empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Produto"))) { reg.Cd_produto = reader.GetString(reader.GetOrdinal("CD_Produto")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Produto"))) { reg.Ds_produto = reader.GetString(reader.GetOrdinal("DS_Produto")); } if (!reader.IsDBNull(reader.GetOrdinal("TP_Registro"))) { reg.Tp_registro = reader.GetString(reader.GetOrdinal("TP_Registro")); } if (!reader.IsDBNull(reader.GetOrdinal("TP_Movimento"))) { reg.Tp_movimento = reader.GetString(reader.GetOrdinal("TP_Movimento")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Conta_CTB_CRED"))) { reg.Cd_conta_ctb_cred = reader.GetDecimal(reader.GetOrdinal("CD_Conta_CTB_CRED")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_ContaCTB_CRED"))) { reg.Ds_conta_ctb_cred = reader.GetString(reader.GetOrdinal("DS_ContaCTB_CRED")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Classificacao_CRED"))) { reg.Cd_classificacao_cred = reader.GetString(reader.GetOrdinal("CD_Classificacao_CRED")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Conta_CTB_DEB"))) { reg.Cd_conta_ctb_deb = reader.GetDecimal(reader.GetOrdinal("CD_Conta_CTB_DEB")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_ContaCTB_DEB"))) { reg.Ds_conta_ctb_deb = reader.GetString(reader.GetOrdinal("DS_ContaCTB_DEB")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Classificacao_DEB"))) { reg.Cd_classificacao_deb = reader.GetString(reader.GetOrdinal("CD_Classificacao_DEB")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { deletarBanco_Dados(); } } return(lista); }
public Model.StoredProcedure[] GetStoredProcedures() { //StoredProcsWithTempReferences.Clear(); const string sql1 = @" SELECT ROUTINE_NAME, ROUTINE_SCHEMA, ROUTINE_DEFINITION, ( SELECT CAST(CASE WHEN tbl.is_ms_shipped = 1 THEN 1 WHEN (SELECT major_id FROM sys.extended_properties WHERE major_id = tbl.object_id AND minor_id = 0 AND class = 1 AND name = N'microsoft_database_tools_support') IS NOT NULL THEN 1 ELSE 0 END AS bit ) AS IsSystemObject FROM sys.procedures AS tbl WHERE (name = T.ROUTINE_NAME)) AS IsSystemObject FROM INFORMATION_SCHEMA.ROUTINES AS T WHERE ROUTINE_TYPE = 'PROCEDURE' ORDER BY ROUTINE_NAME"; // For the databases that are missing some system tables const string sql2 = @" SELECT ROUTINE_NAME, ROUTINE_SCHEMA, ROUTINE_DEFINITION, CAST(CASE WHEN OBJECTPROPERTY(sp.id, N'IsMSShipped') = 1 THEN 1 WHEN OBJECTPROPERTY(sp.id, N'IsSystemTable') = 1 THEN 1 ELSE 0 END AS bit) AS IsSystemObject FROM INFORMATION_SCHEMA.ROUTINES AS T INNER JOIN dbo.sysobjects SP ON SP.name = T.ROUTINE_NAME WHERE ROUTINE_TYPE = 'PROCEDURE' ORDER BY ROUTINE_NAME"; List <StoredProcDef> storedProcedureNames = new List <StoredProcDef>(); //OleDbDataReader oleDbDataReader = null; System.Data.SqlClient.SqlDataReader sqlDataReader = null; try { try { //oleDbDataReader = RunQuerySQL(sql1); sqlDataReader = RunQuerySQL(sql1); } catch (Exception ex) { string message = ex.Message.ToLower(); if (message.IndexOf("schema_name") > 0 || message.IndexOf("invalid object name") >= 0) { //oleDbDataReader = RunQuerySQL(sql2); sqlDataReader = RunQuerySQL(sql2); } else { throw; } } // Exclude system storedProcedures int isSysObjectColumnOrdinal = sqlDataReader.GetOrdinal("IsSystemObject"); while (sqlDataReader.Read()) { bool isSystemObject = sqlDataReader.IsDBNull(isSysObjectColumnOrdinal) ? false : (bool)sqlDataReader[isSysObjectColumnOrdinal]; if (!isSystemObject || Model.Database.IncludeSystemObjects) { //storedProcedureNames.Add(oleDbDataReader["ROUTINE_NAME"].ToString() + "|" + oleDbDataReader["ROUTINE_SCHEMA"].ToString()); storedProcedureNames.Add(new StoredProcDef(sqlDataReader["ROUTINE_NAME"].ToString() + "|" + sqlDataReader["ROUTINE_SCHEMA"].ToString(), sqlDataReader["ROUTINE_DEFINITION"].ToString())); //if (oleDbDataReader["ROUTINE_DEFINITION"].ToString().IndexOf("#") > 0) //{ // StoredProcsWithTempReferences.Add(oleDbDataReader["ROUTINE_NAME"].ToString()); //} } } } finally { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } //StoredProcsWithTempReferences.Sort(); //ProcessProsWithTempReferences(storedProcedureNames); List <Model.StoredProcedure> storedProcedures = new List <Model.StoredProcedure>(); foreach (StoredProcDef storedProcedureNameEx in storedProcedureNames) { string storedProcedureName = storedProcedureNameEx.Name.Split('|')[0]; string schema = storedProcedureNameEx.Name.Split('|')[1]; Model.StoredProcedure storedProcedure = GetNewStoredProcedure(storedProcedureName, schema); storedProcedures.Add(storedProcedure); } return(storedProcedures.ToArray()); }
private void toolStripButtonDEL_Click(object sender, EventArgs e) { if (dataGridViewDJMX.SelectedRows.Count < 1) { MessageBox.Show("请选择要删除的库房", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int i; sqlConn.Open(); sqlComm.CommandText = "SELECT SUM(库存数量) FROM 库存表 "; for (i = 0; i < dataGridViewDJMX.SelectedRows.Count; i++) { if (dataGridViewDJMX.SelectedRows[i].IsNewRow) { continue; } if (i == 0) { sqlComm.CommandText += " WHERE (库房ID = " + dataGridViewDJMX.SelectedRows[i].Cells[0].Value.ToString() + ")"; } else { sqlComm.CommandText += " OR (库房ID = " + dataGridViewDJMX.SelectedRows[i].Cells[0].Value.ToString() + ")"; } } sqldr = sqlComm.ExecuteReader(); int iC = 0; while (sqldr.Read()) { if (sqldr.GetValue(0).ToString() != "") { iC = int.Parse(sqldr.GetValue(0).ToString()); } break; } sqldr.Close(); if (iC == 0) { if (MessageBox.Show("是否删除所选内容?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { sqlConn.Close(); return; } } else { if (MessageBox.Show("是否删除所选内容?库房中尚有" + iC.ToString() + "个库存", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { sqlConn.Close(); return; } } System.Data.SqlClient.SqlTransaction sqlta; sqlta = sqlConn.BeginTransaction(); sqlComm.Transaction = sqlta; try { for (i = 0; i < dataGridViewDJMX.SelectedRows.Count; i++) { if (dataGridViewDJMX.SelectedRows[i].IsNewRow) { continue; } sqlComm.CommandText = "UPDATE 库房表 SET BeActive = 0 WHERE (ID = " + dataGridViewDJMX.SelectedRows[i].Cells[0].Value.ToString() + ")"; sqlComm.ExecuteNonQuery(); } sqlta.Commit(); } catch (Exception ex) { MessageBox.Show("数据库错误:" + ex.Message.ToString(), "数据库错误", MessageBoxButtons.OK, MessageBoxIcon.Error); sqlta.Rollback(); return; } finally { sqlConn.Close(); } MessageBox.Show("删除完毕", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void FormSCDWDJ_Load(object sender, EventArgs e) { sqlConn.ConnectionString = strConn; sqlComm.Connection = sqlConn; sqlDA.SelectCommand = sqlComm; cGetInformation = new ClassGetInformation(strConn); this.Top = 1; this.Left = 1; //得到开始时间 sqlConn.Open(); //sqlComm.CommandText = "SELECT 开始时间 FROM 系统参数表"; sqlComm.CommandText = "SELECT GETDATE()"; sqldr = sqlComm.ExecuteReader(); while (sqldr.Read()) { //dateTimePickerS.Value = Convert.ToDateTime(sqldr.GetValue(0).ToString()); dateTimePickerS.Value = DateTime.Parse(Convert.ToDateTime(sqldr.GetValue(0).ToString()).Year.ToString() + "-" + Convert.ToDateTime(sqldr.GetValue(0).ToString()).Month.ToString() + "-1"); } sqldr.Close(); //初始化员工列表 sqlComm.CommandText = "SELECT ID, 职员编号, 职员姓名 FROM 职员表 WHERE (beactive = 1)"; if (dSet.Tables.Contains("职员表")) { dSet.Tables.Remove("职员表"); } sqlDA.Fill(dSet, "职员表"); object[] OTemp = new object[3]; OTemp[0] = 0; OTemp[1] = "全部"; OTemp[2] = "全部"; dSet.Tables["职员表"].Rows.Add(OTemp); comboBoxYWY.DataSource = dSet.Tables["职员表"]; comboBoxYWY.DisplayMember = "职员姓名"; comboBoxYWY.ValueMember = "ID"; comboBoxYWY.SelectedIndex = comboBoxYWY.Items.Count - 1; sqlComm.CommandText = "SELECT ID, 职员编号, 职员姓名 FROM 职员表 WHERE (beactive = 1)"; if (dSet.Tables.Contains("职员表1")) { dSet.Tables.Remove("职员表1"); } sqlDA.Fill(dSet, "职员表1"); object[] OTemp1 = new object[3]; OTemp1[0] = 0; OTemp1[1] = "全部"; OTemp1[2] = "全部"; dSet.Tables["职员表1"].Rows.Add(OTemp1); comboBoxCZY.DataSource = dSet.Tables["职员表1"]; comboBoxCZY.DisplayMember = "职员姓名"; comboBoxCZY.ValueMember = "ID"; comboBoxCZY.SelectedIndex = comboBoxCZY.Items.Count - 1; sqlConn.Close(); cGetInformation.getSystemDateTime(); string sDT = cGetInformation.strSYSDATATIME; labelZDRQ.Text = Convert.ToDateTime(sDT).ToString("yyyy年M月dd日"); labelCZY.Text = strUserName; comboBoxDJLB.SelectedIndex = 0; }
public TList_Lote_X_NFCe Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { TList_Lote_X_NFCe lista = new TList_Lote_X_NFCe(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = CriarBanco_Dados(false); } try { reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); while (reader.Read()) { TRegistro_Lote_X_NFCe reg = new TRegistro_Lote_X_NFCe(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_Lote"))) { reg.Id_lote = reader.GetDecimal(reader.GetOrdinal("ID_Lote")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_Cupom"))) { reg.Id_cupom = reader.GetDecimal(reader.GetOrdinal("ID_Cupom")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_Processamento"))) { reg.Dt_processamento = reader.GetDateTime(reader.GetOrdinal("DT_Processamento")); } if (!reader.IsDBNull(reader.GetOrdinal("NR_Protocolo"))) { reg.Nr_protocolo = reader.GetDecimal(reader.GetOrdinal("NR_Protocolo")); } if (!reader.IsDBNull(reader.GetOrdinal("DigVal"))) { reg.Digval = reader.GetString(reader.GetOrdinal("DigVal")); } if (!reader.IsDBNull(reader.GetOrdinal("Status"))) { reg.Status = reader.GetDecimal(reader.GetOrdinal("Status")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Mensagem"))) { reg.Ds_mensagem = reader.GetString(reader.GetOrdinal("DS_Mensagem")); } if (!reader.IsDBNull(reader.GetOrdinal("VerAplic"))) { reg.Veraplic = reader.GetString(reader.GetOrdinal("VerAplic")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_clifor"))) { reg.Cd_clifor = reader.GetString(reader.GetOrdinal("cd_clifor")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_clifor"))) { reg.Nm_clifor = reader.GetString(reader.GetOrdinal("nm_clifor")); } if (!reader.IsDBNull(reader.GetOrdinal("dt_emissao"))) { reg.Dt_emissao = reader.GetDateTime(reader.GetOrdinal("dt_emissao")); } if (!reader.IsDBNull(reader.GetOrdinal("nr_nfce"))) { reg.Id_coo_ecf = reader.GetDecimal(reader.GetOrdinal("nr_nfce")); } if (!reader.IsDBNull(reader.GetOrdinal("nr_serie"))) { reg.Nr_serie = reader.GetString(reader.GetOrdinal("nr_serie")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_modelo"))) { reg.Cd_modelo = reader.GetString(reader.GetOrdinal("cd_modelo")); } if (!reader.IsDBNull(reader.GetOrdinal("vl_cupom"))) { reg.Vl_cupom = reader.GetDecimal(reader.GetOrdinal("vl_cupom")); } if (!reader.IsDBNull(reader.GetOrdinal("st_registro"))) { reg.St_registro = reader.GetString(reader.GetOrdinal("st_registro")); } if (!reader.IsDBNull(reader.GetOrdinal("chave_acesso"))) { reg.Chave_acesso = reader.GetString(reader.GetOrdinal("chave_acesso")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_versao"))) { reg.Cd_versao = reader.GetString(reader.GetOrdinal("cd_versao")); } if (!reader.IsDBNull(reader.GetOrdinal("tp_ambiente"))) { reg.Tp_ambiente = reader.GetString(reader.GetOrdinal("tp_ambiente")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { deletarBanco_Dados(); } } return(lista); }
public TList_LiberarCredito Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { bool podeFecharBco = false; TList_LiberarCredito lista = new TList_LiberarCredito(); if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(true); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo)); try { while (reader.Read()) { TRegistro_LiberarCredito reg = new TRegistro_LiberarCredito(); if (!reader.IsDBNull(reader.GetOrdinal("ID_Solicitacao"))) { reg.Id_solicitacao = reader.GetDecimal(reader.GetOrdinal("ID_Solicitacao")); } if (!(reader.IsDBNull(reader.GetOrdinal("CD_Clifor")))) { reg.Cd_clifor = reader.GetString(reader.GetOrdinal("CD_Clifor")); } if (!(reader.IsDBNull(reader.GetOrdinal("NM_Clifor")))) { reg.Nm_clifor = reader.GetString(reader.GetOrdinal("NM_Clifor")); } if (!(reader.IsDBNull(reader.GetOrdinal("LoginBloqueio")))) { reg.Loginbloqueio = reader.GetString(reader.GetOrdinal("LoginBloqueio")); } if (!(reader.IsDBNull(reader.GetOrdinal("LoginDesbloqueio")))) { reg.Logindesbloqueio = reader.GetString(reader.GetOrdinal("LoginDesbloqueio")); } if (!(reader.IsDBNull(reader.GetOrdinal("Vl_Compra")))) { reg.Vl_compra = reader.GetDecimal(reader.GetOrdinal("Vl_Compra")); } if (!(reader.IsDBNull(reader.GetOrdinal("DT_Solicitacao")))) { reg.Dt_solicitacao = reader.GetDateTime(reader.GetOrdinal("DT_Solicitacao")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_Liberacao"))) { reg.Dt_liberacao = reader.GetDateTime(reader.GetOrdinal("DT_Liberacao")); } if (!(reader.IsDBNull(reader.GetOrdinal("DS_ObsBloqueio")))) { reg.Ds_obsbloqueio = reader.GetString(reader.GetOrdinal("DS_ObsBloqueio")); } if (!(reader.IsDBNull(reader.GetOrdinal("DS_ObsLiberacao")))) { reg.Ds_obsliberacao = reader.GetString(reader.GetOrdinal("DS_ObsLiberacao")); } if (!(reader.IsDBNull(reader.GetOrdinal("ST_Registro")))) { reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public TList_CfgCompraAvulsa Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo) { TList_CfgCompraAvulsa lista = new TList_CfgCompraAvulsa(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo)); while (reader.Read()) { TRegistro_CfgCompraAvulsa reg = new TRegistro_CfgCompraAvulsa(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("nm_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("cfg_pedido"))) { reg.Cfg_pedido = reader.GetString(reader.GetOrdinal("cfg_pedido")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_tipopedido"))) { reg.Ds_tipopedido = reader.GetString(reader.GetOrdinal("ds_tipopedido")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_local"))) { reg.Cd_local = reader.GetString(reader.GetOrdinal("cd_local")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_local"))) { reg.Ds_local = reader.GetString(reader.GetOrdinal("ds_local")); } if (!reader.IsDBNull(reader.GetOrdinal("Id_almox"))) { reg.Id_almox = reader.GetDecimal(reader.GetOrdinal("Id_almox")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_almoxarifado"))) { reg.Ds_almox = reader.GetString(reader.GetOrdinal("ds_almoxarifado")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public Model.Table[] GetTables() { const string sql1 = @" SELECT TABLE_NAME, TABLE_SCHEMA, (SELECT CAST( CASE WHEN tbl.is_ms_shipped = 1 THEN 1 WHEN ( SELECT major_id FROM sys.extended_properties WHERE major_id = tbl.object_id AND minor_id = 0 AND class = 1 AND name = N'microsoft_database_tools_support' ) IS NOT NULL THEN 1 ELSE 0 END AS bit) AS IsSystemObject FROM sys.tables AS tbl WHERE name = T.TABLE_NAME AND SCHEMA_NAME(schema_id) = N'dbo') AS IsSystemObject FROM INFORMATION_SCHEMA.TABLES AS T WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME"; // SQL query for databases that are missing various system tables const string sql2 = @" SELECT TABLE_NAME, TABLE_SCHEMA, CAST( CASE WHEN (OBJECTPROPERTY(SO.id, N'IsMSShipped') = 1) THEN 1 WHEN 1 = OBJECTPROPERTY(SO.id, N'IsSystemTable') THEN 1 ELSE 0 END AS bit) AS IsSystemObject FROM INFORMATION_SCHEMA.TABLES AS T INNER JOIN sysobjects SO on T.TABLE_NAME = SO.name WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME"; List <string> tableNames = new List <string>(); //OleDbDataReader oleDbDataReader = null; System.Data.SqlClient.SqlDataReader sqlDataReader = null; try { try { sqlDataReader = RunQuerySQL(sql1); } catch (Exception ex) { if (ex.Message.IndexOf("SCHEMA_NAME") > 0) { sqlDataReader = RunQuerySQL(sql2); } else { throw; } } // Exclude system tables int isSysObjectColumnOrdinal = sqlDataReader.GetOrdinal("IsSystemObject"); while (sqlDataReader.Read()) { bool isSystemObject = sqlDataReader.IsDBNull(isSysObjectColumnOrdinal) ? false : (bool)sqlDataReader[isSysObjectColumnOrdinal]; if (!isSystemObject || Model.Database.IncludeSystemObjects) { tableNames.Add(sqlDataReader["TABLE_NAME"].ToString() + "|" + sqlDataReader["TABLE_SCHEMA"].ToString()); } } } finally { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } List <Model.Table> tables = new List <Model.Table>(); foreach (string tableNameEx in tableNames) { string tableName = tableNameEx.Split('|')[0]; string schema = tableNameEx.Split('|')[1]; Model.Table table = GetNewTable(schema, tableName); table.Schema = schema; tables.Add(table); } return(tables.ToArray()); }
public TList_Contrato_X_DesdEspecial Select(Utils.TpBusca[] vBusca, short vTop, string vNM_Campo) { TList_Contrato_X_DesdEspecial lista = new TList_Contrato_X_DesdEspecial(); bool podeFecharBco = false; if (this.Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo)); try { while (reader.Read()) { TRegistro_Contrato_X_DesdEspecial reg = new TRegistro_Contrato_X_DesdEspecial(); if (!reader.IsDBNull(reader.GetOrdinal("id_tpdesdobro"))) { reg.Id_tpdesdobro = reader.GetDecimal(reader.GetOrdinal("id_tpdesdobro")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_tpdesdobro"))) { reg.Ds_tpdesdobro = reader.GetString(reader.GetOrdinal("ds_tpdesdobro")); } if (!reader.IsDBNull(reader.GetOrdinal("nr_contrato"))) { reg.Nr_contrato = reader.GetDecimal(reader.GetOrdinal("nr_contrato")); } if (!reader.IsDBNull(reader.GetOrdinal("nr_contrato_dest"))) { reg.Nr_contrato_dest = reader.GetDecimal(reader.GetOrdinal("nr_contrato_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa_dest"))) { reg.Cd_empresa_dest = reader.GetString(reader.GetOrdinal("cd_empresa_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_empresa_dest"))) { reg.Nm_empresa_dest = reader.GetString(reader.GetOrdinal("nm_empresa_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_clifor_dest"))) { reg.Cd_clifor_dest = reader.GetString(reader.GetOrdinal("cd_clifor_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_clifor_dest"))) { reg.Nm_clifor_dest = reader.GetString(reader.GetOrdinal("nm_clifor_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_produto_dest"))) { reg.Cd_produto_dest = reader.GetString(reader.GetOrdinal("cd_produto_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_produto_dest"))) { reg.Ds_produto_dest = reader.GetString(reader.GetOrdinal("ds_produto_dest")); } if (!reader.IsDBNull(reader.GetOrdinal("valor_desdobro"))) { reg.Valor_desdobro = reader.GetDecimal(reader.GetOrdinal("valor_desdobro")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public TList_Talhoes Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo) { TList_Talhoes lista = new TList_Talhoes(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo)); while (reader.Read()) { TRegistro_Talhoes reg = new TRegistro_Talhoes(); if (!reader.IsDBNull(reader.GetOrdinal("CD_Fazenda"))) { reg.Cd_fazenda = reader.GetString(reader.GetOrdinal("CD_Fazenda")); } if (!reader.IsDBNull(reader.GetOrdinal("NM_Fazenda"))) { reg.Nm_fazenda = reader.GetString(reader.GetOrdinal("NM_Fazenda")); } if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade"))) { reg.Sigla_unidade = reader.GetString(reader.GetOrdinal("sigla_unidade")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_Area"))) { reg.Id_area = reader.GetDecimal(reader.GetOrdinal("ID_Area")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Area"))) { reg.Ds_area = reader.GetString(reader.GetOrdinal("DS_Area")); } if (!reader.IsDBNull(reader.GetOrdinal("id_talhao"))) { reg.Id_talhao = reader.GetDecimal(reader.GetOrdinal("id_talhao")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Talhao"))) { reg.Ds_talhao = reader.GetString(reader.GetOrdinal("DS_Talhao")); } if (!reader.IsDBNull(reader.GetOrdinal("area_talhao"))) { reg.Area_talhao = reader.GetDecimal(reader.GetOrdinal("area_talhao")); } if (!reader.IsDBNull(reader.GetOrdinal("area_producao"))) { reg.Area_producao = reader.GetDecimal(reader.GetOrdinal("area_producao")); } if (!reader.IsDBNull(reader.GetOrdinal("area_dividida"))) { reg.Area_dividida = reader.GetDecimal(reader.GetOrdinal("area_dividida")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao"))) { reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_Registro"))) { reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_Irrigado"))) { reg.St_irrigado = reader.GetString(reader.GetOrdinal("ST_Irrigado")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public static Bamboo.Mssql.TableColumnCollection ReadTableColumns(string tableName, System.Data.SqlClient.SqlConnection connection) { Bamboo.Mssql.TableColumnCollection columns = new Bamboo.Mssql.TableColumnCollection(); string query = "SELECT COLUMN_NAME, IS_NULLABLE, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.CONSTRAINT_NAME WHERE INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY' AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = INFORMATION_SCHEMA.COLUMNS.TABLE_NAME AND INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.COLUMN_NAME = INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME) AS IS_PRIMARY_KEY, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.CONSTRAINT_NAME WHERE INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'FOREIGN KEY' AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = INFORMATION_SCHEMA.COLUMNS.TABLE_NAME AND INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.COLUMN_NAME = INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME) AS IS_FOREIGN_KEY, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + tableName + "' ORDER BY TABLE_NAME, ORDINAL_POSITION"; System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(query, connection); System.Data.SqlClient.SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { Bamboo.Mssql.TableColumn column = new Bamboo.Mssql.TableColumn(); if (!dataReader.IsDBNull(dataReader.GetOrdinal("COLUMN_NAME"))) { column.Name = dataReader.GetString(dataReader.GetOrdinal("COLUMN_NAME")); } if (!dataReader.IsDBNull(dataReader.GetOrdinal("IS_NULLABLE"))) { string is_nullable = dataReader.GetString(dataReader.GetOrdinal("IS_NULLABLE")).Trim().ToUpper(); if (is_nullable == "YES") { column.IsNullable = true; } else if (is_nullable == "NO") { column.IsNullable = false; } } if (!dataReader.IsDBNull(dataReader.GetOrdinal("IS_PRIMARY_KEY"))) { int count = dataReader.GetInt32(dataReader.GetOrdinal("IS_PRIMARY_KEY")); if (count > 0) { column.IsPrimaryKey = true; } } if (!dataReader.IsDBNull(dataReader.GetOrdinal("IS_FOREIGN_KEY"))) { int count = dataReader.GetInt32(dataReader.GetOrdinal("IS_FOREIGN_KEY")); if (count > 0) { column.IsForeignKey = true; } } if (!dataReader.IsDBNull(dataReader.GetOrdinal("DATA_TYPE"))) { column.Datatype = dataReader.GetString(dataReader.GetOrdinal("DATA_TYPE")); } if (!dataReader.IsDBNull(dataReader.GetOrdinal("CHARACTER_MAXIMUM_LENGTH"))) { column.Length = dataReader.GetInt32(dataReader.GetOrdinal("CHARACTER_MAXIMUM_LENGTH")); } columns.Add(column); } dataReader.Close(); return(columns); }
public void Initial_loadpage() { Literal ltlLatestPicts = (Literal)formpicts.FindControl("ltlLatestPicts"); String strLatestPicts = ""; SqlDataSource sds_outlook = new SqlDataSource(); sds_outlook.DataSourceMode = SqlDataSourceMode.DataReader; //sds_outlook.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_outlook.ConnectionString = str_Data_Source; sds_outlook.SelectCommand = "SELECT fid,f庭院照片_s,f庭院照片_l from T康欣_活動剪影 WHERE f庭院照片_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr庭院 = (System.Data.SqlClient.SqlDataReader)sds_outlook.Select(DataSourceSelectArguments.Empty); SqlDataSource sds_inside = new SqlDataSource(); sds_inside.DataSourceMode = SqlDataSourceMode.DataReader; //sds_inside.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_inside.ConnectionString = str_Data_Source; sds_inside.SelectCommand = "SELECT fid,f內部照片_s,f內部照片_l from T康欣_活動剪影 WHERE f內部照片_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr內部 = (System.Data.SqlClient.SqlDataReader)sds_inside.Select(DataSourceSelectArguments.Empty); SqlDataSource sds_birthday = new SqlDataSource(); sds_birthday.DataSourceMode = SqlDataSourceMode.DataReader; //sds_birthday.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_birthday.ConnectionString = str_Data_Source; sds_birthday.SelectCommand = "SELECT fid,f慶生照片_s,f慶生照片_l from T康欣_活動剪影 WHERE f慶生照片_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr慶生 = (System.Data.SqlClient.SqlDataReader)sds_birthday.Select(DataSourceSelectArguments.Empty); SqlDataSource sds_washfoot = new SqlDataSource(); sds_washfoot.DataSourceMode = SqlDataSourceMode.DataReader; //sds_washfoot.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_washfoot.ConnectionString = str_Data_Source; sds_washfoot.SelectCommand = "SELECT fid,f泡腳照片_s,f泡腳照片_l from T康欣_活動剪影 WHERE f泡腳照片_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr泡腳 = (System.Data.SqlClient.SqlDataReader)sds_washfoot.Select(DataSourceSelectArguments.Empty); SqlDataSource sds_rehab = new SqlDataSource(); sds_rehab.DataSourceMode = SqlDataSourceMode.DataReader; //sds_rehab.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_rehab.ConnectionString = str_Data_Source; sds_rehab.SelectCommand = "SELECT fid,f復健照片_s,f復健照片_l from T康欣_活動剪影 WHERE f復健照片_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr復健 = (System.Data.SqlClient.SqlDataReader)sds_rehab.Select(DataSourceSelectArguments.Empty); SqlDataSource sds_cuthair = new SqlDataSource(); sds_cuthair.DataSourceMode = SqlDataSourceMode.DataReader; //sds_cuthair.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_cuthair.ConnectionString = str_Data_Source; sds_cuthair.SelectCommand = "SELECT fid,f義剪照片_s,f義剪照片_l from T康欣_活動剪影 WHERE f義剪照片_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr義剪 = (System.Data.SqlClient.SqlDataReader)sds_cuthair.Select(DataSourceSelectArguments.Empty); SqlDataSource sds_other = new SqlDataSource(); sds_other.DataSourceMode = SqlDataSourceMode.DataReader; //sds_other.ConnectionString = "Data Source=" + str_Data_Source + ";Initial Catalog=dbKSYY;Integrated Security=True"; sds_other.ConnectionString = str_Data_Source; sds_other.SelectCommand = "SELECT fid,f其他活動_s,f其他活動_l from T康欣_活動剪影 WHERE f其他活動_s IS NOT NULL"; System.Data.SqlClient.SqlDataReader sdr其他 = (System.Data.SqlClient.SqlDataReader)sds_other.Select(DataSourceSelectArguments.Empty); if (sdr庭院.HasRows) { while (sdr庭院.Read()) { strLatestPicts += "<div class='element transition outlook' data-category='transition'>"; strLatestPicts += "<a href='" + sdr庭院["f庭院照片_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr庭院["f庭院照片_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr庭院["f庭院照片_l"].ToString() + "</span>"; strLatestPicts += "</div>"; if (sdr內部.HasRows) { while (sdr內部.Read()) { strLatestPicts += "<div class='element transition inside' data-category='transition'>"; strLatestPicts += "<a href='" + sdr內部["f內部照片_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr內部["f內部照片_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr內部["f內部照片_l"].ToString() + "</span>"; strLatestPicts += "</div>"; if (sdr慶生.HasRows) { while (sdr慶生.Read()) { strLatestPicts += "<div class='element transition birthday' data-category='transition'>"; strLatestPicts += "<a href='" + sdr慶生["f慶生照片_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr慶生["f慶生照片_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr慶生["f慶生照片_l"].ToString() + "</span>"; strLatestPicts += "</div>"; if (sdr泡腳.HasRows) { while (sdr泡腳.Read()) { strLatestPicts += "<div class='element transition washfoot' data-category='transition'>"; strLatestPicts += "<a href='" + sdr泡腳["f泡腳照片_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr泡腳["f泡腳照片_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr泡腳["f泡腳照片_l"].ToString() + "</span>"; strLatestPicts += "</div>"; if (sdr復健.HasRows) { while (sdr復健.Read()) { strLatestPicts += "<div class='element transition rehab' data-category='transition'>"; strLatestPicts += "<a href='" + sdr復健["f復健照片_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr復健["f復健照片_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr復健["f復健照片_l"].ToString() + "</span>"; strLatestPicts += "</div>"; if (sdr義剪.HasRows) { while (sdr義剪.Read()) { strLatestPicts += "<div class='element transition cuthair' data-category='transition'>"; strLatestPicts += "<a href='" + sdr義剪["f義剪照片_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr義剪["f義剪照片_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr義剪["f義剪照片_l"].ToString() + "</span>"; strLatestPicts += "</div>"; if (sdr其他.HasRows) { while (sdr其他.Read()) { strLatestPicts += "<div class='element transition other' data-category='transition'>"; strLatestPicts += "<a href='" + sdr其他["f其他活動_s"].ToString() + "' class='thumb'>"; strLatestPicts += "<figure class='img-polaroid'>"; strLatestPicts += "<img src='" + sdr其他["f其他活動_s"].ToString() + "' alt='' style='width:270px;height:190px'>"; strLatestPicts += "</figure>"; strLatestPicts += "</a><span class='description'>" + sdr其他["f其他活動_l"].ToString() + "</span>"; strLatestPicts += "</div>"; } } } } } } } } } } } } } } ltlLatestPicts.Text = strLatestPicts; }
private void addPurchase_Click(object sender, EventArgs e) { DateTime dateTime = DateTime.UtcNow.Date; var date = dateTime.ToString("dd-MM-yyyy"); var invoiceNo = invoiceTextBox.Text; var sName = supNametextBox.Text; var sAddress = supAddressTextBox.Text; var sContact = supContactTextBox.Text; var dis = discount.Text; var discountAmount = disAmTextBox.Text; var gross_total = grossTotal.Text; var payableTotal = payableAmount.Text; var paymentTotal = payment.Text; var dueTotal = dueAmount.Text; var mode = paymentMode.SelectedItem; var contactCheck = ""; System.Data.SqlClient.SqlConnection connection1 = new System.Data.SqlClient.SqlConnection(connectionString); string supfetchQuery = "SELECT Contact FROM Supplier_Details"; System.Data.SqlClient.SqlCommand commandfetch = new System.Data.SqlClient.SqlCommand(supfetchQuery, connection1); connection1.Open(); System.Data.SqlClient.SqlDataReader reader1 = commandfetch.ExecuteReader(); while (reader1.Read()) { contactCheck = reader1["Contact"].ToString(); } connection1.Close(); //invoice start PInvoiceForm salesReport = new PInvoiceForm(); this.Hide(); salesReport.invoiceNoLabel.Text = "Invoice No : " + invoiceNo.ToString(); salesReport.nameLabel.Text = "Supplier Name :" + sName.ToString(); salesReport.addressLabel.Text = "Address : " + sAddress.ToString(); salesReport.contactlabel.Text = "Contact No :" + sContact.ToString(); // some portion end string StrQuery; try { using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { using (System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand()) { comm.Connection = connection; connection.Open(); if (sContact != contactCheck) { string queryCus = "INSERT INTO Supplier_Details VALUES('" + sName + "','" + sAddress + "','" + sContact + "')"; comm.CommandText = queryCus; comm.ExecuteNonQuery(); } for (int i = 0; i < salesGridView.Rows.Count; i++) { //var pCheck = ""; //var cCheck = ""; //var mCheck = ""; //var stockCheck = ""; //string fetchQuery = "SELECT * FROM StockEntries"; //comm.CommandText = fetchQuery; //System.Data.SqlClient.SqlDataReader reader3 = comm.ExecuteReader(); //while (reader3.Read()) //{ // pCheck = reader3["stock_name"].ToString(); // cCheck = reader3["category"].ToString(); // mCheck = reader3["product_model"].ToString(); // stockCheck = reader3["quantity"].ToString(); //} //connection.Close(); //connection.Open(); //if (pCheck == salesGridView.Rows[i].Cells["productNameTextBox"].Value && cCheck == salesGridView.Rows[i].Cells["catTextBox"].Value && mCheck == salesGridView.Rows[i].Cells["modelTextBox"].Value) //{ // var q = salesGridView.Rows[i].Cells["quantityTextBox"].Value.ToString(); // int s4 = int.Parse(stockCheck); // int q4 = int.Parse(q); // int avail = s4 + q4; // var updatedStock = avail.ToString(); // string updaetQuery = "UPDATE StockEntries SET quantity='" + updatedStock + "' WHERE stock_name='" + salesGridView.Rows[i].Cells["productNameTextBox"].Value + "' AND category='" + salesGridView.Rows[i].Cells["catTextBox"].Value + "' AND product_model='" + salesGridView.Rows[i].Cells["modelTextBox"].Value + "'"; // comm.CommandText = updaetQuery; // comm.ExecuteNonQuery(); //} //else{ StrQuery = @"INSERT INTO StockEntries VALUES ('" + invoiceNo + "','" + salesGridView.Rows[i].Cells["productNameTextBox"].Value + "',' " + salesGridView.Rows[i].Cells["catTextBox"].Value + "', '" + salesGridView.Rows[i].Cells["modelTextBox"].Value + "', '" + sContact + "', '" + salesGridView.Rows[i].Cells["priceTextBox"].Value + "', '" + salesGridView.Rows[i].Cells["quantityTextBox"].Value + "','" + salesGridView.Rows[i].Cells["totalTextBox"].Value + "', '" + dis + "', '" + discountAmount + "', '" + gross_total + "', '" + paymentTotal + "', '" + dueTotal + "', '" + payableTotal + "', '" + mode + "', '" + date + "')"; comm.CommandText = StrQuery; comm.ExecuteNonQuery(); //} salesReport.testdataGridView1.Rows.Insert(0, salesGridView.Rows[i].Cells["productNameTextBox"].Value.ToString(), salesGridView.Rows[i].Cells["catTextBox"].Value.ToString(), salesGridView.Rows[i].Cells["modelTextBox"].Value.ToString(), salesGridView.Rows[i].Cells["priceTextBox"].Value.ToString(), salesGridView.Rows[i].Cells["quantityTextBox"].Value.ToString(), salesGridView.Rows[i].Cells["totalTextBox"].Value.ToString()); } salesGridView.Rows.Clear(); salesGridView.Refresh(); //MessageBox.Show("Successfull!!"); salesReport.dLabel.Text = "Discount : " + dis.ToString() + " %"; //salesReport.disamountLabel.Text = discountAmount.ToString() + "TK"; //salesReport.payableAmountLabel.Text = payableTotal.ToString(); salesReport.gTotalLabel.Text = "Gross Total : " + gross_total.ToString() + " TK"; salesReport.dueLabel.Text = "Due Amount : " + dueTotal.ToString() + " TK"; salesReport.paymentLabel.Text = "Payment Amount : " + paymentTotal.ToString() + " TK"; salesReport.Show(); } } } catch (System.Data.SqlClient.SqlException es) { MessageBox.Show("Error!" + es.Message, "Error"); } }
public TList_ItensGuardaVolume Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo) { TList_ItensGuardaVolume lista = new TList_ItensGuardaVolume(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo)); while (reader.Read()) { TRegistro_ItensGuardaVolume reg = new TRegistro_ItensGuardaVolume(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_GuardaVol"))) { reg.Id_guardavol = reader.GetDecimal(reader.GetOrdinal("ID_GuardaVol")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_ItemGuardaVol"))) { reg.Id_itemguardavol = reader.GetDecimal(reader.GetOrdinal("ID_ItemGuardaVol")); } if (!reader.IsDBNull(reader.GetOrdinal("ID_Item"))) { reg.Id_item = reader.GetDecimal(reader.GetOrdinal("ID_Item")); } if (!reader.IsDBNull(reader.GetOrdinal("Ds_item"))) { reg.Ds_item = reader.GetString(reader.GetOrdinal("Ds_item")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_Locacao"))) { reg.Dt_locacao = reader.GetDateTime(reader.GetOrdinal("DT_Locacao")); } if (!reader.IsDBNull(reader.GetOrdinal("Quantidade"))) { reg.Quantidade = reader.GetDecimal(reader.GetOrdinal("Quantidade")); } if (!reader.IsDBNull(reader.GetOrdinal("QTD_RETIRADA"))) { reg.QTD_RETIRADA = reader.GetDecimal(reader.GetOrdinal("QTD_RETIRADA")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao"))) { reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_Registro"))) { reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
private void btnAccept_Click(object sender, EventArgs e) { int i1 = 0, i2 = 0; string strDateSYS = ""; System.Data.SqlClient.SqlTransaction sqlta; if (!countAmount()) { return; } switch (iStyle) { case 0: //增加 sqlConn.Open(); //查重 if (textBoxDWBH.Text.Trim() == "") { MessageBox.Show("please int code"); sqlConn.Close(); break; } sqlComm.CommandText = "SELECT [Product Name], [Product Code] FROM product WHERE [Product Code]= '" + textBoxDWBH.Text.Trim() + "'"; sqldr = sqlComm.ExecuteReader(); if (sqldr.HasRows) { sqldr.Read(); MessageBox.Show("product code" + textBoxDWBH.Text.Trim() + "duplicate,name is:" + sqldr.GetValue(1).ToString()); sqldr.Close(); sqlConn.Close(); break; } sqldr.Close(); sqlta = sqlConn.BeginTransaction(); sqlComm.Transaction = sqlta; try { sqlComm.CommandText = " ([Product Name], [Product Code], [Number of IMEI], [Failure Rate], Status) VALUES (N'" + textBoxDWMC.Text.Trim() + "', N'" + textBoxDWBH.Text.Trim() + "'," + numericUpDownNum.Value.ToString() + "," + numericUpDownFR.Value.ToString() + ",1)"; sqlComm.ExecuteNonQuery(); sqlComm.CommandText = "SELECT @@IDENTITY"; sqldr = sqlComm.ExecuteReader(); sqldr.Read(); iSelect = Convert.ToInt32(sqldr.GetValue(0).ToString()); sqldr.Close(); sqlta.Commit(); } catch (Exception ex) { MessageBox.Show("error:" + ex.Message.ToString(), "error", MessageBoxButtons.OK, MessageBoxIcon.Error); sqlta.Rollback(); return; } finally { sqlConn.Close(); } MessageBox.Show("add finished", "infomation", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); break; case 1: //修改 sqlConn.Open(); //查重 if (textBoxDWBH.Text.Trim() == "") { MessageBox.Show("please input code"); sqlConn.Close(); break; } iSelect = Convert.ToInt32(dt.Rows[0][0].ToString()); sqlComm.CommandText = "SELECT ID, [Product Name] FROM product WHERE ([Product Code] = '" + textBoxDWBH.Text.Trim() + "' AND ID <> " + iSelect.ToString() + ")"; sqldr = sqlComm.ExecuteReader(); if (sqldr.HasRows) { sqldr.Read(); MessageBox.Show("product code " + textBoxDWBH.Text.Trim() + "duplicate,name is:" + sqldr.GetValue(1).ToString()); sqldr.Close(); sqlConn.Close(); break; } sqldr.Close(); sqlta = sqlConn.BeginTransaction(); sqlComm.Transaction = sqlta; try { iSelect = Convert.ToInt32(dt.Rows[0][0].ToString()); sqlComm.CommandText = "UPDATE product SET [Product Name] = N'" + textBoxDWMC.Text.Trim() + "', [Product Code] = N'" + textBoxDWBH.Text.Trim() + "',[Number of IMEI]=" + numericUpDownNum.Value.ToString() + ",[Failure Rate] = " + numericUpDownFR.Value.ToString() + " WHERE (ID = " + iSelect + ")"; sqlComm.ExecuteNonQuery(); sqlComm.CommandText = "UPDATE acquire SET [Product Code] = N'" + textBoxDWBH.Text.Trim() + "' WHERE ([Product ID] = " + iSelect + ")"; sqlComm.ExecuteNonQuery(); sqlComm.CommandText = "UPDATE actual SET [Product Code] = N'" + textBoxDWBH.Text.Trim() + "' WHERE ([Product ID] = " + iSelect + ")"; sqlComm.ExecuteNonQuery(); sqlComm.CommandText = "UPDATE buyer SET [Product Code] = N'" + textBoxDWBH.Text.Trim() + "' WHERE ([Product ID] = " + iSelect + ")"; sqlComm.ExecuteNonQuery(); sqlComm.CommandText = "UPDATE orders SET [Product Code] = N'" + textBoxDWBH.Text.Trim() + "' WHERE ([Product ID] = " + iSelect + ")"; sqlComm.ExecuteNonQuery(); sqlComm.CommandText = "UPDATE TAC SET [Product Code] = N'" + textBoxDWBH.Text.Trim() + "' WHERE ([Product ID] = " + iSelect + ")"; sqlComm.ExecuteNonQuery(); sqlta.Commit(); } catch (Exception ex) { MessageBox.Show("error:" + ex.Message.ToString(), "error", MessageBoxButtons.OK, MessageBoxIcon.Error); sqlta.Rollback(); return; } finally { sqlConn.Close(); } MessageBox.Show("edit finished", "infomation", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); break; default: break; } }
public TList_Cad_ParamGMO Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { TList_Cad_ParamGMO lista = new TList_Cad_ParamGMO(); bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); try { while (reader.Read()) { TRegistro_Cad_ParamGMO reg = new TRegistro_Cad_ParamGMO(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("nm_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_Historico_Pgto"))) { reg.Cd_historico_pgto = reader.GetString(reader.GetOrdinal("cd_Historico_Pgto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_Historico_Pgto"))) { reg.Ds_historico_pgto = reader.GetString(reader.GetOrdinal("ds_Historico_Pgto")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_Historico_Retencao"))) { reg.Cd_historico_retencao = reader.GetString(reader.GetOrdinal("cd_Historico_Retencao")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_Historico_Retencao"))) { reg.Ds_historico_retencao = reader.GetString(reader.GetOrdinal("ds_Historico_Retencao")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_Contager"))) { reg.Cd_contager = reader.GetString(reader.GetOrdinal("cd_Contager")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_Contager"))) { reg.Ds_contager = reader.GetString(reader.GetOrdinal("ds_Contager")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_Portador"))) { reg.Cd_portador = reader.GetString(reader.GetOrdinal("cd_Portador")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_portador"))) { reg.Ds_portador = reader.GetString(reader.GetOrdinal("ds_portador")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public TList_LoteCustodia Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { bool podeFecharBco = false; TList_LoteCustodia lista = new TList_LoteCustodia(); if (Banco_Dados == null) { this.CriarBanco_Dados(false); podeFecharBco = true; } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo)); try { while (reader.Read()) { TRegistro_LoteCustodia reg = new TRegistro_LoteCustodia(); if (!(reader.IsDBNull(reader.GetOrdinal("ID_Lote")))) { reg.Id_lote = reader.GetDecimal(reader.GetOrdinal("ID_Lote")); } if (!(reader.IsDBNull(reader.GetOrdinal("DS_Lote")))) { reg.Ds_lote = reader.GetString(reader.GetOrdinal("DS_Lote")); } if (!(reader.IsDBNull(reader.GetOrdinal("DT_Lote")))) { reg.Dt_lote = reader.GetDateTime(reader.GetOrdinal("DT_Lote")); } if (!reader.IsDBNull(reader.GetOrdinal("NR_Lote"))) { reg.Nr_lote = reader.GetString(reader.GetOrdinal("NR_Lote")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_EnvioLote"))) { reg.Dt_enviolote = reader.GetDateTime(reader.GetOrdinal("DT_EnvioLote")); } if (!reader.IsDBNull(reader.GetOrdinal("TP_Registro"))) { reg.Tp_registro = reader.GetString(reader.GetOrdinal("TP_Registro")); } if (!(reader.IsDBNull(reader.GetOrdinal("ST_Registro")))) { reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro")); } if (!reader.IsDBNull(reader.GetOrdinal("Cd_Empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("CD_Empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("NM_Empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("NM_Empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Contager"))) { reg.Cd_contager = reader.GetString(reader.GetOrdinal("CD_Contager")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Contager"))) { reg.Ds_contager = reader.GetString(reader.GetOrdinal("DS_Contager")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Banco"))) { reg.Cd_banco = reader.GetString(reader.GetOrdinal("CD_Banco")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Banco"))) { reg.Ds_banco = reader.GetString(reader.GetOrdinal("DS_Banco")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
public TList_CFGLocacao Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo) { TList_CFGLocacao lista = new TList_CFGLocacao(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo)); while (reader.Read()) { TRegistro_CFGLocacao reg = new TRegistro_CFGLocacao(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("nm_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_tabelapreco"))) { reg.Cd_tabelapreco = reader.GetString(reader.GetOrdinal("cd_tabelapreco")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_tabelapreco"))) { reg.Ds_tabelapreco = reader.GetString(reader.GetOrdinal("ds_tabelapreco")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_produto"))) { reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_produto"))) { reg.Ds_produto = reader.GetString(reader.GetOrdinal("ds_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade"))) { reg.Sigla_unidade = reader.GetString(reader.GetOrdinal("sigla_unidade")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_local"))) { reg.Cd_local = reader.GetString(reader.GetOrdinal("cd_local")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_local"))) { reg.Ds_local = reader.GetString(reader.GetOrdinal("ds_local")); } if (!reader.IsDBNull(reader.GetOrdinal("qtd_diasdevolucao"))) { reg.Qtd_diasdevolucao = reader.GetDecimal(reader.GetOrdinal("qtd_diasdevolucao")); } if (!reader.IsDBNull(reader.GetOrdinal("pc_multa"))) { reg.Pc_multa = reader.GetDecimal(reader.GetOrdinal("pc_multa")); } if (!reader.IsDBNull(reader.GetOrdinal("tp_multa"))) { reg.Tp_multa = reader.GetString(reader.GetOrdinal("tp_multa")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
/// <summary> /// Возвращает список объектов "вид отгрузки накладной" из базы данных в виде таблицы значений /// </summary> /// <param name="objProfile">профайл</param> /// <param name="cmdSQL">SQL-команда</param> /// <param name="strErr">сообщение об ошибке</param> /// <returns>таблица</returns> public static System.Data.DataTable GetWaybillShipModeList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL, ref System.String strErr) { System.Data.DataTable dtReturn = new System.Data.DataTable(); dtReturn.Columns.Add(new System.Data.DataColumn("WaybillShipMode_Guid", typeof(System.Data.SqlTypes.SqlGuid))); dtReturn.Columns.Add(new System.Data.DataColumn("WaybillShipMode_Name", typeof(System.Data.SqlTypes.SqlString))); dtReturn.Columns.Add(new System.Data.DataColumn("WaybillShipMode_Description", typeof(System.Data.SqlTypes.SqlString))); dtReturn.Columns.Add(new System.Data.DataColumn("WaybillShipMode_IsActive", typeof(System.Data.SqlTypes.SqlBoolean))); dtReturn.Columns.Add(new System.Data.DataColumn("WaybillShipMode_IsDefault", typeof(System.Data.SqlTypes.SqlBoolean))); dtReturn.Columns.Add(new System.Data.DataColumn("WaybillShipMode_Id", typeof(System.Data.SqlTypes.SqlInt32))); System.Data.SqlClient.SqlConnection DBConnection = null; System.Data.SqlClient.SqlCommand cmd = null; try { if (cmdSQL == null) { DBConnection = objProfile.GetDBSource(); if (DBConnection == null) { strErr += ("\nНе удалось получить соединение с базой данных."); return(dtReturn); } cmd = new System.Data.SqlClient.SqlCommand(); cmd.Connection = DBConnection; cmd.CommandType = System.Data.CommandType.StoredProcedure; } else { cmd = cmdSQL; cmd.Parameters.Clear(); } cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetWaybillShipMode]", objProfile.GetOptionsDllDBName()); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000)); cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output; System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader(); if (rs.HasRows) { System.Data.DataRow newRow = null; while (rs.Read()) { newRow = dtReturn.NewRow(); newRow["WaybillShipMode_Guid"] = (System.Guid)rs["WaybillShipMode_Guid"]; newRow["WaybillShipMode_Name"] = ((rs["WaybillShipMode_Name"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["WaybillShipMode_Name"])); newRow["WaybillShipMode_Description"] = ((rs["WaybillShipMode_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["WaybillShipMode_Description"])); newRow["WaybillShipMode_IsActive"] = ((rs["WaybillShipMode_IsActive"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["WaybillShipMode_IsActive"])); newRow["WaybillShipMode_IsDefault"] = ((rs["WaybillShipMode_IsDefault"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["WaybillShipMode_IsDefault"])); newRow["WaybillShipMode_Id"] = ((rs["WaybillShipMode_Id"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["WaybillShipMode_Id"])); dtReturn.Rows.Add(newRow); } dtReturn.AcceptChanges(); } rs.Dispose(); if (cmdSQL == null) { cmd.Dispose(); DBConnection.Close(); } } catch (System.Exception f) { strErr += ("\nНе удалось получить список объектов \"вид отгрузки накладной\". Текст ошибки: " + f.Message); } return(dtReturn); }
public TList_CFGVendasExterna Select(Utils.TpBusca[] vBusca, int vTop, string vNm_Campo) { TList_CFGVendasExterna lista = new TList_CFGVendasExterna(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = CriarBanco_Dados(false); } try { reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo)); while (reader.Read()) { TRegistro_CFGVendasExterna reg = new TRegistro_CFGVendasExterna(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("nm_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_uf"))) { reg.Cd_uf_empresa = reader.GetString(reader.GetOrdinal("cd_uf")); } if (!reader.IsDBNull(reader.GetOrdinal("Login"))) { reg.Login = reader.GetString(reader.GetOrdinal("Login")); } if (!reader.IsDBNull(reader.GetOrdinal("Senha"))) { reg.Senha = reader.GetString(reader.GetOrdinal("Senha")); } if (!reader.IsDBNull(reader.GetOrdinal("Licenca"))) { reg.Licenca = reader.GetString(reader.GetOrdinal("Licenca")); } if (!reader.IsDBNull(reader.GetOrdinal("Integracao"))) { reg.Integracao = reader.GetString(reader.GetOrdinal("Integracao")); } if (!reader.IsDBNull(reader.GetOrdinal("TP_Duplicata"))) { reg.Tp_duplicata = reader.GetString(reader.GetOrdinal("TP_Duplicata")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_TpDuplicata"))) { reg.Ds_tpduplicata = reader.GetString(reader.GetOrdinal("DS_TpDuplicata")); } if (!reader.IsDBNull(reader.GetOrdinal("TP_Docto"))) { reg.Tp_docto = reader.GetDecimal(reader.GetOrdinal("TP_Docto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_tpdocto"))) { reg.Ds_tpdocto = reader.GetString(reader.GetOrdinal("ds_tpdocto")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_condpgto"))) { reg.Cd_condpgto = reader.GetString(reader.GetOrdinal("cd_condpgto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_condpgto"))) { reg.Ds_condpgto = reader.GetString(reader.GetOrdinal("ds_condpgto")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_historico"))) { reg.Cd_historico = reader.GetString(reader.GetOrdinal("cd_historico")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_historico"))) { reg.Ds_historico = reader.GetString(reader.GetOrdinal("ds_historico")); } if (!reader.IsDBNull(reader.GetOrdinal("id_config"))) { reg.Id_config = reader.GetDecimal(reader.GetOrdinal("id_config")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_config"))) { reg.Ds_config = reader.GetString(reader.GetOrdinal("ds_config")); } if (!reader.IsDBNull(reader.GetOrdinal("CFG_Pedido"))) { reg.Cfg_pedido = reader.GetString(reader.GetOrdinal("CFG_Pedido")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_TipoPedido"))) { reg.Ds_tipopedido = reader.GetString(reader.GetOrdinal("DS_TipoPedido")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { deletarBanco_Dados(); } } return(lista); }
public List <Tipo60R> Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { List <Tipo60R> retorno = new List <Tipo60R>(); bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); try { while (reader.Read()) { Tipo60R reg = new Tipo60R(); if (!reader.IsDBNull(reader.GetOrdinal("Mes"))) { reg.Mes = reader.GetInt32(reader.GetOrdinal("Mes")); } if (!reader.IsDBNull(reader.GetOrdinal("Ano"))) { reg.Ano = reader.GetInt32(reader.GetOrdinal("Ano")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Produto"))) { reg.Cd_produto = reader.GetString(reader.GetOrdinal("CD_Produto")); } if (!reader.IsDBNull(reader.GetOrdinal("Pc_aliquota"))) { reg.Pc_aliquota = reader.GetDecimal(reader.GetOrdinal("pc_aliquota")); } if (!reader.IsDBNull(reader.GetOrdinal("Quantidade"))) { reg.Quantidade = reader.GetDecimal(reader.GetOrdinal("Quantidade")); } if (!reader.IsDBNull(reader.GetOrdinal("Vl_subtotal"))) { reg.Vl_subtotal = reader.GetDecimal(reader.GetOrdinal("Vl_subtotal")); } if (!reader.IsDBNull(reader.GetOrdinal("Vl_basecalc"))) { reg.Vl_basecalc = reader.GetDecimal(reader.GetOrdinal("Vl_basecalc")); } if (!reader.IsDBNull(reader.GetOrdinal("TP_Situacao"))) { reg.Tp_situacao = reader.GetString(reader.GetOrdinal("TP_Situacao")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_SubstTrib"))) { reg.St_substTrib = reader.GetString(reader.GetOrdinal("ST_SubstTrib")); } retorno.Add(reg); } return(retorno); } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } }
public TList_LanLoteNFE_X_NotaFiscal Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo) { TList_LanLoteNFE_X_NotaFiscal lista = new TList_LanLoteNFE_X_NotaFiscal(); System.Data.SqlClient.SqlDataReader reader = null; bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } try { reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); while (reader.Read()) { TRegistro_LanLoteNFE_X_NotaFiscal reg = new TRegistro_LanLoteNFE_X_NotaFiscal(); if (!reader.IsDBNull(reader.GetOrdinal("ID_Lote"))) { reg.Id_lote = reader.GetDecimal(reader.GetOrdinal("ID_Lote")); } if (!reader.IsDBNull(reader.GetOrdinal("CD_Empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("CD_Empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("Nr_LanctoFiscal"))) { reg.Nr_lanctofiscal = reader.GetDecimal(reader.GetOrdinal("Nr_LanctoFiscal")); } if (!reader.IsDBNull(reader.GetOrdinal("NR_NotaFiscal"))) { reg.Nr_notafiscal = reader.GetDecimal(reader.GetOrdinal("NR_NotaFiscal")); } if (!reader.IsDBNull(reader.GetOrdinal("NR_Serie"))) { reg.Nr_serie = reader.GetString(reader.GetOrdinal("NR_Serie")); } if (!reader.IsDBNull(reader.GetOrdinal("DT_Processamento"))) { reg.Dt_processamento = reader.GetDateTime(reader.GetOrdinal("DT_Processamento")); } if (!reader.IsDBNull(reader.GetOrdinal("Nr_Protocolo"))) { reg.Nr_protocolo = reader.GetDecimal(reader.GetOrdinal("Nr_Protocolo")); } if (!reader.IsDBNull(reader.GetOrdinal("DigitoVerificado"))) { reg.Digitoverificado = reader.GetString(reader.GetOrdinal("DigitoVerificado")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Mensagem"))) { reg.Ds_mensagem = reader.GetString(reader.GetOrdinal("DS_Mensagem")); } if (!reader.IsDBNull(reader.GetOrdinal("Status"))) { reg.Status = reader.GetDecimal(reader.GetOrdinal("status")); } if (!reader.IsDBNull(reader.GetOrdinal("Chave_Acesso_Nfe"))) { reg.Chave_acesso_nfe = reader.GetString(reader.GetOrdinal("Chave_Acesso_NFE")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_Registro"))) { reg.St_nfe = reader.GetString(reader.GetOrdinal("ST_Registro")); } if (!reader.IsDBNull(reader.GetOrdinal("ST_Transcanc_nfe"))) { reg.St_transcanc_nfe = reader.GetString(reader.GetOrdinal("ST_TransCanc_nfe")).Trim().ToUpper().Equals("S"); } if (!reader.IsDBNull(reader.GetOrdinal("veraplic"))) { reg.Veraplic = reader.GetString(reader.GetOrdinal("veraplic")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_clifor"))) { reg.Cd_clifor = reader.GetString(reader.GetOrdinal("cd_clifor")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_clifor"))) { reg.Nm_clifor = reader.GetString(reader.GetOrdinal("nm_clifor")); } if (!reader.IsDBNull(reader.GetOrdinal("vl_totalnota"))) { reg.Vl_totalnota = reader.GetDecimal(reader.GetOrdinal("vl_totalnota")); } if (!reader.IsDBNull(reader.GetOrdinal("dt_proccanc"))) { reg.Dt_procCanc = reader.GetDateTime(reader.GetOrdinal("dt_proccanc")); } if (!reader.IsDBNull(reader.GetOrdinal("nr_protocolocanc"))) { reg.Nr_protocoloCanc = reader.GetDecimal(reader.GetOrdinal("nr_protocolocanc")); } if (!reader.IsDBNull(reader.GetOrdinal("tp_ambiente"))) { reg.Tp_ambiente = reader.GetString(reader.GetOrdinal("tp_ambiente")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
/// <summary> /// 获取blob类型的字段值 /// </summary> /// <param name="strSql"></param> /// <returns></returns> public byte[] GetLargeField(string strSql) { this.command.Connection = this.Conn as System.Data.SqlClient.SqlConnection; this.command.Transaction = Mder.FC.DB.DBTrans.Trans as System.Data.SqlClient.SqlTransaction; command.CommandText = strSql + ""; command.CommandType = System.Data.CommandType.Text; System.Data.SqlClient.SqlDataReader reader; command.Parameters.Clear(); try { reader = command.ExecuteReader(); } catch (System.Data.SqlClient.SqlException ex) { this.Err = "执行产生错误!" + ex.Message; this.ErrCode = strSql; this.DBErrCode = ex.ErrorCode; this.WriteErr(); return null; } catch (Exception ex) { this.Err = ex.Message; this.WriteErr(); return null; } reader.Read(); byte[] byteData = new byte[0]; try { byteData = (byte[])(reader[0]); } catch (Exception ex) { this.Err = ex.Message; reader.Close(); return null; } reader.Close(); return byteData; }