protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); Rs1 = new Recordset(); Rs2 = new Recordset(); Rs3 = new Recordset(); Rs4 = new Recordset(); StationID = Request["StationID"]; UserID = Session["UserID"]; SecLevel = Session["SecLevel"]; Barcode = Request["Barcode"]; ProductType = Request["ProductType"]; CarPlate = Request["CarPlate"]; Response.Write(StationID); Response.Write(UserID); Response.Write(SecLevel); Response.End(); iMessage = null; Rs1.Open(("Exec Checkrange '" + Barcode + "'"), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1); //Response.write ("Exec Checkrange '"&Barcode&"'") //Response.end if (Rs1.Eof) { Message = "Check Range ���ҥ��� - §��L��!"; Response.Redirect("CouponVerification.aspx?Message=" + Message); } else { if (Convert.ToDateTime(Rs1.Fields["Expiry_Date"].Value) < DateTime.Parse(Convert.ToString(DateTime.Now))) { Message = "���ҥ��� - §��L��!"; Response.Redirect("CouponVerification.aspx?Message=" + Message); } } Rs1.Close(); Rs1 = null; Rs2.Open(("Exec CheckCouponExist '" + Barcode + "'"), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1); //Response.write ("Exec CheckCouponExist '"&Barcode&"'") iCount = Rs2.Fields["iCount"].Value; Rs2.Close(); Rs2 = null; if (Convert.ToInt32(iCount) > 0) { Message = "���ҥ��� - ���ƨϥ�!"; } else { Session.Add("SecLevel", SecLevel); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("Insert.aspx?ProductType=" + ProductType + "&Barcode=" + Barcode + "&CarPlate=" + CarPlate); } Session.Add("SecLevel", SecLevel); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("CouponVerification.aspx?Message=" + Message + "&Coupon_Number=" + Convert.ToString(Coupon_Number)); }
protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); Recordset Rs1 = null; object StationID = null; object UserID = null; object SecLevel = null; string Barcode = ""; string ProductType = ""; string CarPlate = ""; string Message = ""; Rs1 = new Recordset(); StationID = Session["StationID"]; UserID = Session["UserID"]; SecLevel = Session["SecLevel"]; Barcode = Request["Barcode"]; ProductType = Request["ProductType"]; CarPlate = Request["CarPlate"]; Message = "ÅçÃÒ¦¨¥\\!"; Rs1.Open(("Exec InsertCoupon '" + Barcode + "', '" + Convert.ToString(StationID) + "','" + ProductType + "','" + CarPlate + "','" + Convert.ToString(UserID) + "' "), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1); Response.Redirect("CouponVerification.aspx?Message=" + Message + "&CarPlate=" + CarPlate + "&ProductType=" + ProductType); }
protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); UserID = Request["UserID"]; Password = Request["Password"]; if (Session["StationID"] != null) { StationID = Session["StationID"].ToString(); } Rs1 = new Recordset(); Rs1.Open(("Exec CheckLoginPwd '" + UserID + "', '" + Password + "' "), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1); if (!(Rs1.Eof)) { Session.Add("SecLevel", Rs1.Fields["SecLevel"].Value); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("CouponVerification.aspx"); } else { Response.Redirect("Default.aspx?Message=Fail"); } }
public static string ExecuteCoupon(string StationID, string Barcode, string CarPlate, string ProductType, string UserID) //public static string ExecuteCoupon( string Barcode) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); Recordset Rs1 = null; Recordset Rs2 = null; Recordset Rs3 = null; Recordset Rs4 = null; object SecLevel = null; object iMessage = null; string Message = ""; object iCount = null; string Face_Value = ""; string Coupon_Type = ""; string Coupon_batch = ""; string Coupon_Number = ""; string Sql = ""; object UnitPrice = null; string Sql1 = ""; Rs1 = new Recordset(); Rs2 = new Recordset(); Rs3 = new Recordset(); Rs4 = new Recordset(); // Stationid = StationID; // UserID = HttpContext.Current.Session["UserID"]; // SecLevel = HttpContext.Current.Session["SecLevel"]; iMessage = null; Rs1.Open(("Exec VerifyCoupon '" + Barcode + "','" + StationID + "','" + ProductType + "','" + CarPlate + "','" + UserID + "'"), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1); // Rs1.Open(("Exec VerifyCoupon '" + Barcode + "'"), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1); string result = Rs1.Fields["result"].Value.ToString(); string coupon_number = ""; string date = ""; if(Rs1.Fields["coupon_number"] != null) { coupon_number = Rs1.Fields["coupon_number"].Value.ToString(); } if (Rs1.Fields["Present_Date"] != null) { date = Rs1.Fields["Present_Date"].Value.ToString(); //DateTime d1; //DateTime d = DateTime.TryParse(date,out d1); DateTime? d = null; DateTime d2; bool success = DateTime.TryParse(date, out d2); if (success) d = d2; date = d2.ToString("MM/dd/yyyy HH:mm:ss"); } // Response.Redirect("CouponVerification.aspx?Message=" + Message + "&Coupon_Number=" + Coupon_Number); return result + "@" + coupon_number + "@" + date; }
public Boolean Excluir() { if (this.ID == 0) { return(false); } String SQL = "", SQLProduto = ""; Recordset rs_dados = new Recordset(); Connection conex = new SIME.Conexao().getDb4(); try { rs_dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); rs_dados.Open(SQLProduto, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); //Processo de adiciona ao estoque a quantidade vendida estornada rs_dados.Fields["Estoque"].Value = Convert.ToInt32(rs_dados.Fields["Estoque"].Value) + this.Quantidade; rs_dados.Close(); conex.Close(); } catch (Exception) { throw new ArgumentException("Não foi possível exluir o item."); } return(true); }
public List <String[]> getListaProdutos(Int32 ID) { Connection conex = new Conexao().getDb4(); List <String[]> retorno = new List <String[]>(); String SQL = "SELECT PRODUTOS.Cod, PRODUTOS.Descrição, PRODUTOS.Codbarras, PRODUTOS.desc, expr5, expr7 FROM PRODUTOS WHERE (((PRODUTOS.Cod)=" + ID + "));"; if (dados.State != 0) { this.dados.Close(); } dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (dados.EOF || dados.BOF) { throw new ArgumentException("ID de produto inválido."); } while (!(dados.BOF || dados.EOF)) { String[] conteudo = new String[6]; conteudo[0] = dados.Fields["cod"].Value.ToString(); conteudo[1] = dados.Fields["Descrição"].Value.ToString(); conteudo[2] = dados.Fields["Codbarras"].Value.ToString(); conteudo[3] = dados.Fields["Desc"].Value.ToString(); conteudo[4] = dados.Fields["Expr5"].Value.ToString(); conteudo[5] = dados.Fields["expr7"].Value.ToString(); retorno.Add(conteudo); dados.MoveNext(); } return(retorno); }
public Boolean salvar() { String SQL = "INSERT INTO inventário2013 ( ID_produto, EAN, ID_usuario, Quantidade, Quantidade_anterior, Data ) " + "SELECT " + idProduto + ",'" + EAN + "'," + idUsuario + ", " + quantidade + ", " + qAnterior + ", #" + data.Month + "/" + data.Day + "/" + data.Year + "#;"; try { produto.setEAN(this.EAN); produto.setquantEstoque(this.quantidade); produto.salvar(false); if (rsDados.State != 0) { rsDados.Close(); } rsDados.Open(SQL, new Conexao().getDb4(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); } catch (Exception erro) { throw new ArgumentException(erro.Message); } return(true); }
/// <summary> /// Metodo criado para Salvar os dados do cliente /// </summary> /// <param name="conex">ADODB.Connection</param> /// <returns>Boolean </returns> public Boolean salvar() { RSDados = new Recordset(); if (this.cnpj != null && this.razao != null) { if (this.ID == 0) { SQL = "SELECT loja_venda.* FROM loja_venda;"; RSDados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); RSDados.AddNew(); } else { SQL = "SELECT loja_venda.* FROM loja_venda WHERE(((loja_venda.CNPJ)='" + cnpj + "'));"; RSDados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); } RSDados.Fields["CNPJ"].Value = this.cnpj; RSDados.Fields["Razão"].Value = this.razao; RSDados.Update(); this.ID = Convert.ToInt16(RSDados.Fields["ID"].Value); RSDados.Close(); return(true); } return(false); }
//Checks if a character exists within the database public bool DoesCharacterExist(int ClientID, string CharacterName) { Console.WriteLine("checking if " + CharacterName + " character already exists"); string Query = "SELECT * FROM characters WHERE CharacterName='" + CharacterName + "'"; recorder.Open(Query, connection, cursorType, lockType); bool CharacterExists = !recorder.EOF; recorder.Close(); return(CharacterExists); }
public Boolean salvar() { String SQL = ""; Recordset RSDados = new Recordset(); Connection conex = new Conexao().getDb4(); DateTime hoje = DateTime.Now; if (this.Id == 0) { SQL = "INSERT INTO Entradas ( Cod, Quantidade, Data, [S/n], Cod_fornecedor, Nota, DataNota, [Local], Op ) " + "SELECT " + this.Id_produto + ", " + this.quantidade + ", #" + hoje.Day + "/" + hoje.Month + "/" + hoje.Year + "#, " + this.sn + ", " + this.id_fornecedor + ", '" + this.Nf + "', #" + this.dataNF.Day + "/" + this.dataNF.Month + "/" + this.dataNF.Year + "#, " + this.Id_empresa + ", " + this.Id_operador + ";"; } else { SQL = "UPDATE Entradas SET " + "Entradas.Cod = " + this.Id_produto + ", " + "Entradas.Quantidade = " + this.quantidade + ", " + "Entradas.Data = #" + hoje.Day + "/" + hoje.Month + "/" + hoje.Year + "#, " + "Entradas.[S/n] = " + this.sn + ", " + "Entradas.Cod_fornecedor = " + this.id_fornecedor + ", " + "Entradas.Nota = '" + this.Nf + "', " + "Entradas.DataNota = #" + this.dataNF.Day + "/" + this.dataNF.Month + "/" + this.dataNF.Year + "#, " + "Entradas.[Local] = " + this.Id_empresa + ", " + "Entradas.Op = " + this.Id_operador + " WHERE (((Entradas.Id)=" + this.Id + "));"; } RSDados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (Id == 0) { SQL = "SELECT Last(Entradas.Id) AS ÚltimoDeId FROM Entradas;"; RSDados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); Id = Convert.ToInt32(RSDados.Fields["ÚltimoDeId"].Value.ToString()); RSDados.Close(); } conex.Close(); return(true); }
private void SubWeightsFromLayerThickness() { Recordset rs = new RecordsetClass(); Recordset recordset2 = rs; recordset2.Open("select * from [Soil profile] where R_id=" + Conversions.ToString((int)this.m_RunID), this.frmMain.DatabaseConnection, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockPessimistic, -1); int num4 = ReadSaveFunctions.RecordCount(ref rs); int num2 = 1; while (true) { float num3; int num6 = num4; if (num2 > num6) { recordset2.MoveFirst(); short index = 1; int num5 = ReadSaveFunctions.RecordCount(ref rs); num2 = 1; while (true) { num6 = num5; if (num2 > num6) { recordset2 = null; this.DisplayWeights(); return; } if (Conversions.ToBoolean(Operators.AndObject(Operators.CompareObjectGreaterEqual(recordset2[]["layer_no"][], Conversions.ToShort(this.txtFrom.Text), false), Operators.CompareObjectLessEqual(recordset2[]["layer_no"][], Conversions.ToShort(this.lblToLayer.Text), false))))
private void coletaDados() { if (this.ID == 0) { return; } try { String SQL = "SELECT Saída.*, PRODUTOS.Descrição FROM Saída LEFT JOIN PRODUTOS ON Saída.[Cod do CD] = PRODUTOS.Cod WHERE (((Saída.cont)=" + this.ID + "));"; Recordset rs_dados = new Recordset(); Connection conex = new SIME.Conexao().getDb4(); rs_dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); this.ID_fornecedor = !(rs_dados.Fields["Fornecedor"].Value.ToString().Equals(DBNull.Value)) ? Convert.ToInt32(rs_dados.Fields["Fornecedor"].Value) : 0; this.ID_loja = Convert.ToInt32(rs_dados.Fields["Loja"].Value); this.ID_produto = Convert.ToInt32(rs_dados.Fields["Cod do CD"].Value); this.NF = (rs_dados.Fields["NF"].Value.Equals(DBNull.Value)) ? "0" : rs_dados.Fields["NF"].Value; this.Quantidade = !(rs_dados.Fields["Quantidade"].Value.ToString().Equals(DBNull.Value))? Convert.ToInt32(rs_dados.Fields["Quantidade"].Value):0; this.Unitario = !(rs_dados.Fields["Desconto"].Value.ToString().Equals(DBNull.Value))? Convert.ToDouble(rs_dados.Fields["Desconto"].Value.ToString("N")) : 0; this.Custo = Convert.ToDouble(rs_dados.Fields["Custo"].Value.ToString("N")); this.ID_venda = Convert.ToInt32(rs_dados.Fields["cod_sai"].Value); this.descricao = !(rs_dados.Fields["Descrição"].Value.ToString().Equals(DBNull.Value))?rs_dados.Fields["Descrição"].Value.ToString(): "Produto não cadastrado ID =" + this.ID_produto; rs_dados.Close(); conex.Close(); } catch (Exception e) { throw new ArgumentException("Metodo coletaDados Objeto Item_venda Erro: " + e.Message); } }
private void SaveToCacheRs(string Key, string FullPathToSave) { CreateCacheFolder(); string FullPathCache = GetFullPathCacheRs(Key); if (!File.Exists(FullPathCache)) { CreateRs(FullPathCache, false); } Recordset Rs = new Recordset(); Rs.Open(FullPathCache, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1); string Criteria = "Key = '" + Key.Replace("'", "''") + "'"; Rs.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value); if (!Rs.EOF) { Rs.Fields["Content"].AppendChunk(CFile.GetByteFromFile(FullPathToSave)); } else { Rs.AddNew(Missing.Value, Missing.Value); Rs.Fields["Key"].Value = Key; Rs.Fields["Content"].AppendChunk(CFile.GetByteFromFile(FullPathToSave)); } Rs.Save(FullPathCache, PersistFormatEnum.adPersistXML); Rs.Close(); Rs = null; }
private void coletaDados() { String SQL = "SELECT Fornecedores.* FROM Fornecedores WHERE (((Fornecedores.Cod)=" + id + "));"; Recordset RSDados = new Recordset(); Connection conex = new Conexao().getContas(); RSDados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (RSDados.BOF || RSDados.EOF) { throw new ArgumentException("ID inválido."); } this.nome = (RSDados.Fields["FORNECEDOR"].Value.Equals(DBNull.Value))?"": RSDados.Fields["FORNECEDOR"].Value.ToString().ToUpper(); this.razao = (RSDados.Fields["RAZÃO"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["RAZÃO"].Value.ToString().ToUpper(); this.CNPJ = (RSDados.Fields["CNPJ"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["CNPJ"].Value.ToString().ToUpper(); this.IE = (RSDados.Fields["ESTADUAL"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["ESTADUAL"].Value.ToString().ToUpper(); this.Endereco = (RSDados.Fields["END"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["END"].Value.ToString().ToUpper(); this.cidade = (RSDados.Fields["cidade"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["cidade"].Value.ToString().ToUpper(); this.UF = (RSDados.Fields["estado"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["estado"].Value.ToString().ToUpper(); this.CEP = (RSDados.Fields["CEP"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["CEP"].Value.ToString().ToUpper(); this.bairro = (RSDados.Fields["Bairro"].Value.Equals(DBNull.Value)) ? "" : RSDados.Fields["Bairro"].Value.ToString().ToUpper(); this.numero = (RSDados.Fields["numero"].Value.Equals(DBNull.Value)) ? 0 : Convert.ToInt32(RSDados.Fields["numero"].Value.ToString()); RSDados.Close(); conex.Close(); }
/// <summary> /// Método que coleta no banco de dados os itens de uma determinada venda. /// </summary> /// <param name="ID_venda">Inteiro que contém ID da venda</param> private void coletaItens(Int32 ID_venda) { String SQL = "SELECT Saída.* FROM Saída WHERE (((Saída.cod_sai)=" + ID_venda + "));"; Item_venda item; Recordset rs_dados = new Recordset(); Connection conex = new Conexao().getDb4(); rs_dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (rs_dados.EOF || rs_dados.BOF) { throw new ArgumentException("Id de venda inválida ou não registrada."); } this.itens.Clear(); while (!(rs_dados.BOF || rs_dados.EOF)) { Int32 IDVenda = Convert.ToInt32(rs_dados.Fields["cont"].Value.ToString()); try { item = new Item_venda(IDVenda); } catch (Exception e) { throw new ArgumentException("Objeto: Venda Método: ColetaIntes Erro: " + e.Message); } this.itens.Add(item); rs_dados.MoveNext(); } rs_dados.Close(); conex.Close(); }
protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); Rs1 = new Recordset(); Rs2 = new Recordset(); Rs3 = new Recordset(); Rs4 = new Recordset(); StationID = Request["StationID"]; UserID = Session["UserID"]; SecLevel = Session["SecLevel"]; Barcode = Request["Barcode"]; ProductType = Request["ProductType"]; CarPlate = Request["CarPlate"]; Response.Write(StationID); Response.Write(UserID); Response.Write(SecLevel); Response.End(); iMessage = null; Rs1.Open(("Exec Checkrange '" + Barcode + "'"), conn, (nce.adodb.CursorType) 3, (nce.adodb.LockType) 1); //Response.write ("Exec Checkrange '"&Barcode&"'") //Response.end if (Rs1.Eof) { Message = "Check Range 驗證失敗 - 禮券無效!"; Response.Redirect("CouponVerification.aspx?Message=" + Message); } else { if (Convert.ToDateTime(Rs1.Fields["Expiry_Date"].Value) < DateTime.Parse(Convert.ToString(DateTime.Now))) { Message = "驗證失敗 - 禮券過期!"; Response.Redirect("CouponVerification.aspx?Message=" + Message); } } Rs1.Close(); Rs1 = null; Rs2.Open(("Exec CheckCouponExist '" + Barcode + "'"), conn, (nce.adodb.CursorType) 3, (nce.adodb.LockType) 1); //Response.write ("Exec CheckCouponExist '"&Barcode&"'") iCount = Rs2.Fields["iCount"].Value; Rs2.Close(); Rs2 = null; if (Convert.ToInt32(iCount) > 0) { Message = "驗證失敗 - 重複使用!"; } else { Session.Add("SecLevel", SecLevel); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("Insert.aspx?ProductType=" + ProductType + "&Barcode=" + Barcode + "&CarPlate=" + CarPlate); } Session.Add("SecLevel", SecLevel); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("CouponVerification.aspx?Message=" + Message + "&Coupon_Number=" + Convert.ToString(Coupon_Number)); }
private void coletaDados(String SQL) { Recordset dados = new Recordset(); Connection conex = new Conexao().getDb4(); dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (!(dados.EOF || dados.BOF)) { this.chaveNFE = dados.Fields["Chave_NFE"].Value.ToString(); this.id = Convert.ToInt32(dados.Fields["ID_NF"].Value.ToString()); this.id_fornecedor = Convert.ToInt32(dados.Fields["ID_Forncedor"].Value.ToString()); this.NF_numero = dados.Fields["NF_numero"].Value.ToString(); this.data_emissao = Convert.ToDateTime(dados.Fields["data"].Value.ToString()); this.data_entrada = Convert.ToDateTime(dados.Fields["Data_inclusão"].Value.ToString()); this.icms_antecipado = Convert.ToDouble(dados.Fields["Imposto_pago"].Value.ToString()); //processo que reconhe os itens guaradado em string no banco de dados String[] listaItens = dados.Fields["itens"].Value.ToString().Split(','); this.itens = new Int32[listaItens.Length]; for (int i = 0; i < listaItens.Length; i++) { itens[i] = Convert.ToInt32(listaItens[i]); } this.local = dados.Fields["local"].Value.ToString(); } else { throw new ArgumentException("NF não cadastrada."); } dados.Close(); conex.Close(); }
/// <summary> /// Checks whether the properties required to establish a connection properly /// have already been set. /// </summary> /// <returns></returns> protected bool IsConnectionAvailable() { bool result = true; if (string.IsNullOrEmpty(ConnectionString) || string.IsNullOrEmpty(RecordSource) || string.IsNullOrEmpty(FactoryName)) { _isConnectionAvailable = false; result = false; } if (!_isConnectionAvailable) { if (result) { if (!Recordset.Opened) { InitRecordset(); Recordset.Open(); } if (!Recordset.Opened || Recordset.Tables.Count <= 0) { result = false; } } _isConnectionAvailable = result; } return(_isConnectionAvailable); }
public static UsuariosBO GetUsuarios(string Usuario, ADODB.Connection Cn) { var Usuarios = new UsuariosBO(); var RsUsuarios = new Recordset(); try { RsUsuarios.Open(String.Format("SELECT * FROM dbo.Usuarios WHERE Usuario = '" + Usuario + "'"), Cn, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly); if (!RsUsuarios.EOF) { Usuarios.Usuario = RsUsuarios.Fields["Usuario"].Value.ToString(); Usuarios.SenhaAcesso = RsUsuarios.Fields["SenhaAcesso"].Value.ToString(); Usuarios.TokenAcesso = RsUsuarios.Fields["TokenAcesso"].Value.ToString(); return(Usuarios); } else { return(new UsuariosBO()); } } catch (Exception) { throw; } }
private void coletaDados() { if (this.ID == 0) { return; } String SQL = "SELECT Saída.* FROM Saída WHERE (((Saída.cod_sai)=" + this.ID_venda + "));"; Recordset rs_dados = new Recordset(); Connection conex = new SIME.Conexao().getDb4(); try { rs_dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); this.ID_fornecedor = Convert.ToInt32(rs_dados.Fields["Fornecedor"].Value); this.ID_loja = Convert.ToInt32(rs_dados.Fields["Loja"].Value); this.ID_produto = Convert.ToInt32(rs_dados.Fields["[cod do cd]"].Value); this.NF = rs_dados.Fields["NF"].Value; this.Quantidade = Convert.ToInt32(rs_dados.Fields["Quantidade"].Value); this.Unitario = Convert.ToDouble(rs_dados.Fields["Desconto"].Value.ToString("N")); this.Custo = Convert.ToDouble(rs_dados.Fields["Custo"].Value.ToString("N")); this.descricao = new SIME.Class.Produto(ID_produto, new SIME.Conexao().getDb4()).getDescricao(); rs_dados.Close(); conex.Close(); } catch (Exception e) { throw new ArgumentException(e.Message); } }
/// <summary> /// Método que exclui a venda como também desfaz os lançamentos de cada item repondo as quantidades em estoque. /// </summary> /// <returns></returns> public bool Excluir(Int32 ID_caixa) { if (this.ID_caixa != ID_caixa) { throw new ArgumentException("Não é permitido excluir uma venda de um caixa já fechado!"); } if (vendaFechada == false) { throw new ArgumentException("Não é peritido excluir venda estando aberta."); } //Excluindo a venda Recordset rsDados = new Recordset(); Connection conex = new Conexao().getDb4(); String SQL = "DELETE Cod_sai.Cod_sai FROM Cod_sai WHERE (((Cod_sai.Cod_sai)=" + this.ID + "));"; rsDados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); //Excluindo itens e gravando nos produtos foreach (var item in itens) { item.Excluir(); } rsDados.Close(); conex.Close(); return(true); }
/// <summary> /// Clone Job Validation Error Recordset /// </summary> /// <param name="rs"></param> /// <returns></returns> private Recordset CloneValidationRS(Recordset rs) { int cnt = 1; Recordset rsValidation = new Recordset(); rsValidation.CursorLocation = CursorLocationEnum.adUseClient; rs.MoveFirst(); foreach (Field fld in rs.Fields) { rsValidation.Fields.Append(fld.Name, fld.Type, fld.DefinedSize, (FieldAttributeEnum)fld.Attributes, null); } // Add column ID to recordset to access each row in record set with primary key rsValidation.Fields.Append("ID", DataTypeEnum.adInteger, 10, FieldAttributeEnum.adFldUpdatable); rsValidation.Fields.Append("OVERRIDE_COMMENTS", DataTypeEnum.adVarChar, 400, FieldAttributeEnum.adFldUpdatable); rsValidation.Open(); while (!rs.EOF) { rsValidation.AddNew(); foreach (Field fld in rs.Fields) { rsValidation.Fields[fld.Name].Value = fld.Value; } rsValidation.Fields["ID"].Value = cnt; cnt += 1; rs.MoveNext(); } return(rsValidation); }
private void coletaDados(Int32 ID_cliente) { if (ID_cliente != 0) { SQL = "SELECT Aparelhos.Cod_cliente, Tipo_aparelho.Aparelho, Tipo_marca.Marca, OS_Entragas.Data, Aparelhos.modelo, Aparelhos.Cod " + "FROM ((Aparelhos INNER JOIN Tipo_aparelho ON Aparelhos.cod_tipo = Tipo_aparelho.Cod) INNER JOIN Tipo_marca ON Aparelhos.cod_marca = Tipo_marca.Cod) INNER JOIN OS_Entragas ON Aparelhos.Cod = OS_Entragas.OS " + "WHERE (((Aparelhos.Cod_cliente)=" + ID_cliente + "))ORDER BY Aparelhos.Cod DESC;"; } else { SQL = "SELECT Aparelhos.Cod, Tipo_aparelho.Aparelho, Tipo_marca.Marca, Aparelhos.modelo, Aparelhos.Cod_cliente, OS_Entragas.Data " + "FROM (Tipo_marca INNER JOIN (Tipo_aparelho INNER JOIN Aparelhos ON Tipo_aparelho.Cod = Aparelhos.cod_tipo) ON Tipo_marca.Cod = Aparelhos.cod_marca) LEFT JOIN OS_Entragas ON Aparelhos.Cod = OS_Entragas.Cod " + "WHERE (((Aparelhos.Cod_cliente)=%)) ORDER BY Aparelhos.Cod DESC;"; } listaAparelhos.Clear(); if (RSDados.State != 0) { RSDados.Close(); } RSDados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); while (!(RSDados.EOF || RSDados.BOF)) { listaAparelhos.Add(new String[] { Convert.ToString(RSDados.Fields["cod"].Value), Convert.ToString(RSDados.Fields["Aparelho"].Value), Convert.ToString(RSDados.Fields["Marca"].Value), Convert.ToString(RSDados.Fields["Modelo"].Value), Convert.ToString(RSDados.Fields["data"].Value) }); RSDados.MoveNext(); } }
/// <summary> /// Show Dialog containing Job Validation Errors /// return recordset with user added justification comments for each error /// </summary> /// <param name="rsValidation"></param> /// <returns></returns> public Recordset ShowValidationComments(Recordset rsValidation) { List <WRValidationOverride> wrValidationUsrComments = null; Recordset rsJobValidation = CopyStructure(rsValidation); Recordset rsJobValidationErrs = CloneValidationRS(rsValidation); wrValidationUsrComments = FormatValidationErrors(rsJobValidationErrs); validationRuleOvr = new ValidationRuleOverrides(wrValidationUsrComments); if (validationRuleOvr.ShowDialog(gtApp.ApplicationWindow) == DialogResult.Cancel) { rsJobValidation = null; } else { wrValidationUsrComments = validationRuleOvr.WRValidationComments; rsJobValidationErrs.MoveFirst(); rsJobValidation.Open(); //Update Job Validation Recordset with justification comments while (!rsJobValidationErrs.EOF) { rsJobValidation.AddNew(); foreach (Field fld in rsJobValidation.Fields) { rsJobValidation.Fields[fld.Name].Value = rsJobValidationErrs.Fields[fld.Name].Value; } rsJobValidation.Fields["OVERRIDE_COMMENTS"].Value = wrValidationUsrComments.FirstOrDefault(a => a.ID == Convert.ToInt32(rsJobValidationErrs.Fields["ID"].Value)).Override_Comments; rsJobValidationErrs.MoveNext(); } } return(rsJobValidation); }
public static bool session_valid(string sdate) { try { ADODB.Connection ADOconn = new ADODB.Connection(); ADODB.Recordset tmp = new ADODB.Recordset(); SqlConnectionStringBuilder decoder = new SqlConnectionStringBuilder(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ConnectionString); ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0); ADODB.Recordset rec = new ADODB.Recordset(); string sql = "SELECT FINANCE_ID FROM FINANCE_SESSION WHERE FINANCE_STATUS=1 AND '" + sdate + "' between finance_start_date and finance_end_date"; Recordset TMP = new Recordset(); TMP.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1); if (TMP.RecordCount == 0) { return(false); } else { return(true); } } catch (Exception ex) { return(false); } }
static public _Recordset GetRecordsetFromXml(string xml) { _Stream stream = null; try { stream = new ADODB.Stream(); stream.Open(Missing.Value, ConnectModeEnum.adModeUnknown, StreamOpenOptionsEnum.adOpenStreamUnspecified, "", ""); stream.WriteText(xml, StreamWriteEnum.adWriteChar); stream.Position = 0; var recordset = new Recordset(); recordset.Open(stream, Missing.Value, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, 0); return(recordset); } catch (Exception ex) { ErrorLog.LogError(ex, new CallingMethod()); return(default(_Recordset)); } finally { if (stream != null) { Marshal.ReleaseComObject(stream); } } }
public object GetCachedData(string Key) { string FullPathContent = GetFullPathCacheContent(Key); if (FullPathContent == "") { return(null); } if (this.mUseAdo) { Recordset Rs = new Recordset(); Rs.Open(FullPathContent, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1); return(Rs); } else { DataTable dt = null; try { DataSet ds = new DataSet(); ds.ReadXml(FullPathContent); dt = ds.Tables[0]; } catch (Exception) { dt = new DataTable(); dt.ReadXml(FullPathContent); } return(dt); } }
/// <summary> /// Metodo coleta os dados da venda baseado no ID informado no argumento de entrada /// </summary> /// <param name="ID">Inteiro com n° da Venda </param> private void coletaDados(Int32 ID) { String SQL = "SELECT Cod_sai.* FROM Cod_sai WHERE (((Cod_sai.Cod_sai)=" + ID + "));"; Recordset rs_dados = new Recordset(); Connection conex = new Conexao().getDb4(); rs_dados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (rs_dados.EOF || rs_dados.BOF) { throw new ArgumentException("Id de venda inválida ou não registrada."); } //coletando dados da venda this.ID_cliente = Convert.ToInt32(rs_dados.Fields["cod_cliente"].Value.ToString()); this.ID_vendedor = Convert.ToInt32(rs_dados.Fields["OP"].Value.ToString()); this.ID_caixa = Convert.ToInt32(rs_dados.Fields["CX"].Value.ToString()); this.Especie = Convert.ToDouble(rs_dados.Fields["especie"].Value.ToString("N")); this.Cheque = Convert.ToDouble(rs_dados.Fields["cheque"].Value.ToString("N")); this.Vale = Convert.ToDouble(rs_dados.Fields["Vale"].Value.ToString("N")); this.Total = this.Vale + this.Cheque + this.Cartao + this.Especie; this.orcamentoSmall = rs_dados.Fields["dado1"].Value.ToString(); this.Data = Convert.ToDateTime(rs_dados.Fields["data"].Value); rs_dados.Close(); conex.Close(); coletaItens(ID); this.vendaFechada = true; }
public Recordset ToRecordSet() { var recordSet = new Recordset(); foreach (var field in _metaData.Fields) { recordSet.Fields.Append(field.Name, field.AdodbDataType, field.DefinedSize, field.Attribute, null); } recordSet.Open(Missing.Value, Missing.Value, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, 0); for (var i = 0; i < _records.Count; i++) { recordSet.AddNew(Missing.Value, Missing.Value); for (var j = 0; j < _metaData.Fields.Length; j++) { recordSet.Fields[j].Value = _records[i][j]; } if (i == _records.Count - 1) recordSet.MoveFirst(); else recordSet.MoveNext(); } return recordSet; }
protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); UserID = Request["UserID"]; Password = Request["Password"]; if (Session["StationID"] != null) { StationID = Session["StationID"].ToString(); } Rs1 = new Recordset(); Rs1.Open(("Exec CheckLoginPwd '" + UserID + "', '" + Password + "' "), conn, (nce.adodb.CursorType) 3, (nce.adodb.LockType) 1); if (!(Rs1.Eof)) { Session.Add("SecLevel", Rs1.Fields["SecLevel"].Value); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("CouponVerification.aspx"); } else { Response.Redirect("Default.aspx?Message=Fail"); } }
private void coletaDados() { if (RsDados.State != 0) { RsDados.Close(); } RsDados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); if (RsDados.EOF || RsDados.BOF) { throw new ArgumentException("Regra repassada não é válida."); } this.ID = Convert.ToInt32(RsDados.Fields["cod"].Value); this.regra = Convert.ToString(RsDados.Fields["Regra"].Value); this.ICMSD = Convert.ToDouble(RsDados.Fields["ICMSD"].Value); this.percentualICMS = Convert.ToDouble(RsDados.Fields["PercentualICMS"].Value); this.federal = Convert.ToDouble(RsDados.Fields["Federal"].Value); this.PercentualFederal = Convert.ToDouble(RsDados.Fields["PercentualFederal"].Value); this.ICMSD_fora = Convert.ToDouble(RsDados.Fields["ICMSD_fora"].Value); this.percentualICMS_fora = Convert.ToDouble(RsDados.Fields["PercentualICMS_fora"].Value); this.informativo = Convert.ToString(RsDados.Fields["Texto"].Value); this.TxFixa = (RsDados.Fields["TxFixas"].Value.Equals(DBNull.Value)) ? 0 : Convert.ToDouble(RsDados.Fields["TxFixas"].Value.ToString()); this.CSOSN = (RsDados.Fields["csosn"].Value.Equals(DBNull.Value)) ? "102" : RsDados.Fields["csosn"].Value.ToString(); this.ST = (RsDados.Fields["ST"].Value.Equals(DBNull.Value)) ? "" : RsDados.Fields["ST"].Value.ToString(); this.CST = (RsDados.Fields["CST"].Value.Equals(DBNull.Value)) ? "0" : RsDados.Fields["CST"].Value.ToString(); this.IAT = (RsDados.Fields["IAT"].Value.Equals(DBNull.Value)) ? "T" : RsDados.Fields["IAT"].Value.ToString(); this.IPPT = (RsDados.Fields["IPPT"].Value.Equals(DBNull.Value)) ? "T" : RsDados.Fields["IPPT"].Value.ToString(); }
/// <summary> /// Método que faz emparelhamento com os dados do SIME com SMALL /// </summary> public void indexar() { Recordset rsDadosSime = new Recordset(); Recordset rsDadosSmall = new Recordset(); String SQL1; //, SQL2; Connection conex1 = new Conexao().getDb4(); //Connection conex2 = new Conexao().getSmall(); Produto item; SQL1 = "SELECT PRODUTOS.* FROM PRODUTOS ORDER BY PRODUTOS.Cod;"; //SQL2 = "SELECT ESTOQUE.* FROM ESTOQUE ORDER BY ESTOQUE.CODIGO;"; //Procedimentos Verificar se o produto está cadastrado no Small //Se estiver ver se há quantidade em estoque igual a do Sime //Se não estiver incluir o produto //Se a quantidade estiver diferente fazer ajuste do Small com o sime. rsDadosSime.Open(SQL1, conex1, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); //rsDadosSmall.Open(SQL2, conex2, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic); while (!(rsDadosSime.EOF || rsDadosSime.BOF)) { item = new Produto(Convert.ToInt32(rsDadosSime.Fields["cod"].Value), conex1); item.salvarSmall(); rsDadosSime.MoveNext(); } rsDadosSime.Close(); conex1.Close(); }
/// <summary> /// Get Paged Records /// </summary> /// <param name="query"></param> /// <param name="source"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="cursorType"></param> /// <param name="lockType"></param> /// <param name="options"></param> /// <param name="cursorLocation"></param> /// <returns></returns> public Recordset GetPagedRecords(string query, DataSource source, int pageIndex, int pageSize = 100, CursorTypeEnum cursorType = CursorTypeEnum.adOpenDynamic, LockTypeEnum lockType = LockTypeEnum.adLockOptimistic, CommandTypeEnum options = CommandTypeEnum.adCmdText, CursorLocationEnum cursorLocation = CursorLocationEnum.adUseClient) { _connection = new Connection(); var cnStr = GetConnectionString(source); _connection.Open(cnStr, null, null, 0); _recordSet = new Recordset { CursorLocation = cursorLocation, CacheSize = pageSize, PageSize = pageSize }; //_recordSet.Open(query,_connection, cursorType, lockType, (int)options); _recordSet.Open(query, _connection); if (_recordSet.RecordCount != 0) { _recordSet.AbsolutePage = (PositionEnum)pageIndex; } return(_recordSet); }
protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); Recordset Rs1 = null; object StationID = null; object UserID = null; object SecLevel = null; string Barcode = ""; string ProductType = ""; string CarPlate = ""; string Message = ""; Rs1 = new Recordset(); StationID = Session["StationID"]; UserID = Session["UserID"]; SecLevel = Session["SecLevel"]; Barcode = Request["Barcode"]; ProductType = Request["ProductType"]; CarPlate = Request["CarPlate"]; Message = "ÅçÃÒ¦¨¥\\!"; Rs1.Open(("Exec InsertCoupon '" + Barcode + "', '" + Convert.ToString(StationID) + "','" + ProductType + "','" + CarPlate + "','" + Convert.ToString(UserID) + "' "), conn, (nce.adodb.CursorType) 3, (nce.adodb.LockType) 1); Session.Add("SecLevel", SecLevel); Session.Add("UserID", UserID); Session.Add("StationID", StationID); Response.Redirect("CouponVerification.aspx?Message=" + Message + "&CarPlate=" + CarPlate + "&ProductType=" + ProductType); }
private string GetFullPathCacheContent(string Key) { if (string.IsNullOrEmpty(this.mCacheFolder)) { throw new Exception("CacheFolder 값이 없습니다"); } string FullPathTemp = ""; if (this.mUseAdo) { string FullPathCache = GetFullPathCacheRs(Key); //Remove 메쏘드로 삭제하다 더 이상 행이 없으면 파일 자체가 삭제됨 if (!File.Exists(FullPathCache)) { return(""); } Recordset Rs = new Recordset(); Rs.Open(FullPathCache, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1); string Criteria = "Key = '" + Key.Replace("'", "''") + "'"; Rs.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value); if (Rs.EOF) { Rs.Close(); return(""); } FullPathTemp = CFile.GetTempFileName(); CAdo.GetFileFromField(Rs.Fields["Content"], FullPathTemp); } else { string FullPathCache = GetFullPathCacheDt(Key); //Remove 메쏘드로 삭제하다 더 이상 행이 없으면 파일 자체가 삭제됨 if (!File.Exists(FullPathCache)) { return(""); } DataTable dt = new DataTable(); dt.ReadXml(FullPathCache); string Criteria = "Key = '" + Key.Replace("'", "''") + "'"; DataRow[] adr = dt.Select(Criteria); if (adr.Length == 0) { dt = null; return(""); } DataRow dr = adr[0]; FullPathTemp = CFile.GetTempFileName(); CFile.WriteByteToFile(FullPathTemp, (byte[])dr["Content"]); } return(FullPathTemp); }
public ActionResult TagListEditor_Post(HttpPostedFileBase fileupload) { OleDbDataAdapter _odbAdapter = new OleDbDataAdapter(); DataTable _dtable = new DataTable(); if (fileupload != null && fileupload.ContentLength > 0) { string _filename = Path.GetFileName(fileupload.FileName); string _fileExtension = Path.GetExtension(fileupload.FileName); string _path = Path.Combine(Server.MapPath("~/App_Data"), _filename); string _newFile = Path.Combine(Server.MapPath("~/App_Data"), _filename.Replace(_fileExtension,".txt")); if (_fileExtension == ".rs") { fileupload.SaveAs(_path); fileupload.SaveAs(_newFile); Recordset _recordset = new Recordset(); _recordset.Open(_path); _odbAdapter.Fill(_dtable, _recordset); _dtable.Columns.Add("Actions",typeof(string)); //foreach (DataRow dt in _dtable.Rows) //{ // dt["Actions"] = ""; //} //_dtable.AcceptChanges(); StreamWriter _sWriter = new StreamWriter(_newFile, false); foreach (DataRow drow in _dtable.Rows) { for (int i = 0; i < _dtable.Columns.Count; i++) { if (!Convert.IsDBNull(drow[i])) { if (i == 1) { _sWriter.Write("|" + drow[i].ToString()); } else { _sWriter.Write(drow[i].ToString()); } } } _sWriter.Write(_sWriter.NewLine); } _sWriter.Close(); } } return View(_dtable); }
protected ADODB.Recordset ExecuteIntoRecordset(string sql, IDbConnection cn) { Recordset oRS = new Recordset(); IDataReader reader = null; try { IDbCommand command = cn.CreateCommand(); command.CommandText = sql; command.CommandType = CommandType.Text; reader = command.ExecuteReader(); DataTable schema; string dataType, fieldname; int length; bool firstTime = true; // Skip columns contains the index of any columns that we cannot handle, array types and such ... Hashtable skipColumns = null; while (reader.Read()) { if (firstTime) { skipColumns = new Hashtable(); schema = reader.GetSchemaTable(); int colID = 0; foreach (DataRow row in schema.Rows) { fieldname = row["ColumnName"].ToString(); dataType = row["DataType"].ToString(); length = Convert.ToInt32(row["ColumnSize"]); try { oRS.Fields.Append(fieldname, GetADOType(dataType), length, FieldAttributeEnum.adFldIsNullable, System.Reflection.Missing.Value); } catch { // We can't handle this column type, ie, Firebird array types skipColumns[colID] = colID; } colID++; } oRS.Open(System.Reflection.Missing.Value, System.Reflection.Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 1); firstTime = false; } oRS.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value); for(int i = 0, j = 0; i < reader.FieldCount; i++) { // Skip columns that we cannot handle if(!skipColumns.ContainsKey(i)) { if (reader[j] is System.Guid) { oRS.Fields[j].Value = "{" + reader[j].ToString() + "}"; } else { try { oRS.Fields[j].Value = reader[j]; } catch { // For some reason it wouldn't accept this value? oRS.Fields[j].Value = DBNull.Value; } } j++; } } } cn.Close(); //Move to the first record if (!firstTime) { oRS.MoveFirst(); } else { oRS = null; } } catch (Exception ex) { if ((reader != null) && (!reader.IsClosed)) { reader.Close(); reader = null; } if ((cn != null) && (cn.State == ConnectionState.Open)) { cn.Close(); cn = null; } throw ex; } return oRS; }
protected void Page_Load(object sender, EventArgs e) { conn = new Connection(); string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString; conn.Open(connectionstring); UserIPAddress = GetIPAddress(); //For Demo //UserIPAddress = "192.168.1.12"; //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"]; Rs1 = new Recordset(); sql1 = "Select * From Station s Left Join CVSUser u on "; sql1 = sql1 + " s.LoginUser = u.UserName Where IPAddress ='" + UserIPAddress + "'"; Rs1 = conn.Execute(sql1); StationID = (Rs1.Fields["Station"].Value).ToString().Trim(); UserID = (Rs1.Fields["LoginUser"].Value).ToString().Trim(); SecLevel = (Rs1.Fields["SecLevel"].Value).ToString().Trim(); if (UserID == "") { Response.Redirect("Default.aspx"); } Message = Request["Message"]; Coupon_Number = Request["Coupon_Number"]; Car_No = Request["Car_No"]; Face_Value = Request["Face_Value"]; Period = Request["Period"]; //search by date if (Request["SDay"] != null) { SDay = Request["SDay"]; SMonth = Request["SMonth"]; SYear = Request["SYear"]; } else { SDay = Convert.ToString(DateTime.Now.Day); SMonth = Convert.ToString(DateTime.Now.Month); SYear = Convert.ToString(DateTime.Now.Year); } if (Request["NDay"] != null) { NDay = Request["NDay"]; NMonth = Request["NMonth"]; NYear = Request["NYear"]; } else { NDay = Convert.ToString(DateTime.Now.Day); NMonth = Convert.ToString(DateTime.Now.Month); NYear = Convert.ToString(DateTime.Now.Year); } //Search_Date = Formatdatetime(DateSerial(SYear, SMonth, SDay),2) //Search_NDate = Formatdatetime(DateSerial(NYear, NMonth, NDay),2) Search_Date = SDay + "/" + SMonth + "/" + SYear; Search_NDate = NDay + "/" + NMonth + "/" + NYear; //Response.write search_date //response.write SecLevel & "<br>" //response.write UserID if (Request.Form["pageid"] != null) pageid = (Request.Form["pageid"]).Trim(); if (pageid == "") { pageid = "1"; } if (Request.Form["Barcode"] != null) { Barcode = (Request.Form["Barcode"]).Trim().Replace("%", "%"); Barcode = Barcode.Replace("'", "''"); if (Barcode.Length == 15) { Face_Value = Barcode.Substring(0, 3); Coupon_Type = Barcode.Substring(5 - 1, 2); Coupon_batch = Barcode.Substring(7 - 1, 3); Coupon_Number = Barcode.Substring(10 - 1, 6); } } fsql = "select * from MasterCoupon where RequestedID = " + Convert.ToString(StationID); //Search Coupon Number //******************** if (Barcode != "") { if (Barcode.Length == 15) { fsql = fsql + " and Coupon_Number = '" + Coupon_Number + "'"; fsql = fsql + " and Face_Value = '" + Face_Value + "'"; fsql = fsql + " and Coupon_Type = '" + Coupon_Type + "'"; fsql = fsql + " and Coupon_Batch = '" + Coupon_batch + "'"; } else { fsql = fsql + " and Coupon_Number LIKE '%" + Barcode + "%' "; } } fsql = fsql + " and Present_Date >= Convert(datetime, '" + Convert.ToString(Search_Date) + "', 105) "; fsql = fsql + " and Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Convert.ToString(Search_NDate) + "', 105)),0) + 1 "; //By UserID if (Convert.ToString(SecLevel).Trim() == "1") { fsql = fsql + " and Period = '" + Convert.ToString(UserID) + "' "; } fsql = fsql + " order by id desc"; frs = new Recordset(); frs.CursorType = (nce.adodb.CursorType)1; frs.LockType = (nce.adodb.LockType)1; Rs1.Close(); frs.Open(fsql, conn); }
virtual public ADODB.Recordset ExecuteSql(string sql) { Recordset oRS = new Recordset(); OleDbConnection cn = null; OleDbDataReader reader = null; try { cn = new OleDbConnection(dbRoot.ConnectionString); cn.Open(); try { cn.ChangeDatabase(this.Name); } catch { } // some databases don't have the concept of catalogs. Catch this and throw it out OleDbCommand command = new OleDbCommand(sql, cn); command.CommandType = CommandType.Text; reader = command.ExecuteReader(); DataTable schema; string dataType, fieldname; int length; bool firstTime = true; while (reader.Read()) { if (firstTime) { schema = reader.GetSchemaTable(); foreach (DataRow row in schema.Rows) { fieldname = row["ColumnName"].ToString(); dataType = row["DataType"].ToString(); length = Convert.ToInt32(row["ColumnSize"]); oRS.Fields.Append(fieldname, GetADOType(dataType), length, FieldAttributeEnum.adFldIsNullable, System.Reflection.Missing.Value); } oRS.Open(System.Reflection.Missing.Value, System.Reflection.Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 1); firstTime = false; } oRS.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value); for(int i = 0; i < reader.FieldCount; i++) { if (reader[i] is System.Guid) { oRS.Fields[i].Value = "{" + reader[i].ToString() + "}"; } else { oRS.Fields[i].Value = reader[i]; } } } cn.Close(); //Move to the first record if (!firstTime) { oRS.MoveFirst(); } else { oRS = null; } } catch (Exception ex) { if ((reader != null) && (!reader.IsClosed)) { reader.Close(); reader = null; } if ((cn != null) && (cn.State == ConnectionState.Open)) { cn.Close(); cn = null; } throw ex; } return oRS; }