public List <ChangeAssets> ConsultAllAssetVisible(Asset AssetE) { IDbConnection _conn = DBComon.Connectiondb(); _conn.Open(); SqlCommand _command = new SqlCommand("CONSULT_CHANGE_ASSET", _conn as SqlConnection); _command.CommandType = CommandType.StoredProcedure; _command.Parameters.Add(new SqlParameter("@id", AssetE.IdAssets)); IDataReader _reader = _command.ExecuteReader(); List <ChangeAssets> ListA = new List <ChangeAssets>(); ChangeAssets _c; while (_reader.Read()) { _c = new ChangeAssets(); _c.idAssetsfk = _reader.GetInt32(0); _c.idLocationfkch = _reader.GetInt32(1); _c.idResponsiblefkch = _reader.GetInt32(2); _c.pedimento = _reader.GetString(3); _c.codePedimento = _reader.GetString(4); _c.dateChange = _reader.GetDateTime(5); _c.notes = _reader.GetString(6); _c.invoice = _reader.GetString(7); _c.invoiceDate = _reader.GetDateTime(8); _c.PO = _reader.GetString(9); _c.provider = _reader.GetString(10); _c.owner = _reader.GetString(11); ListA.Add(_c); } _conn.Close(); return(ListA); }
public int AddChangeAsset(ChangeAssets ChangeAE) { IDbConnection _conn = DBComon.Connectiondb(); _conn.Open(); SqlCommand _command = new SqlCommand("ADD_CHANGE_ASSET", _conn as SqlConnection); _command.CommandType = CommandType.StoredProcedure; _command.Parameters.Add(new SqlParameter("@idA", ChangeAE.idAssetsfk)); _command.Parameters.Add(new SqlParameter("@idLoc", ChangeAE.idLocationfkch)); _command.Parameters.Add(new SqlParameter("@idRes", ChangeAE.idResponsiblefkch)); _command.Parameters.Add(new SqlParameter("@ped", ChangeAE.pedimento)); _command.Parameters.Add(new SqlParameter("@cPe", ChangeAE.codePedimento)); _command.Parameters.Add(new SqlParameter("@vis", ChangeAE.visible)); _command.Parameters.Add(new SqlParameter("@dateCh", ChangeAE.dateChange)); _command.Parameters.Add(new SqlParameter("@notes", ChangeAE.notes)); _command.Parameters.Add(new SqlParameter("@invo", ChangeAE.invoice)); if (ChangeAE.invoiceDate == null) { _command.Parameters.Add(new SqlParameter("@invoD", DBNull.Value)); } else { _command.Parameters.Add(new SqlParameter("@invoD", ChangeAE.invoiceDate)); } _command.Parameters.Add(new SqlParameter("@po", ChangeAE.PO)); _command.Parameters.Add(new SqlParameter("@ow", ChangeAE.owner)); _command.Parameters.Add(new SqlParameter("@prov", ChangeAE.provider)); int result = _command.ExecuteNonQuery(); _conn.Close(); return(result); }
private void UpdateBd() { try { //Update _aObject.pedimento = txtped.Text; _aObject.codePedimento = txtpedcod.Text; _aObject.idLocationfk = Convert.ToInt32(cmbLoc.SelectedIndex.ToString()) + 1; _aObject.idResponsiblefk = Convert.ToInt32(cmbResp.SelectedIndex.ToString()) + 1; _aObject.notes = txtNote.Text; _aObject.PO = txtOrden.Text; _aObject.costmx = Convert.ToDecimal(txtcostMx.Text); _aObject.invoice = txtinvo.Text; _aObject.owner = cmbCond.Text; _aObject.provider = txtprov.Text; if (txtinvoD.Text != " / /") { date = ""; day = ""; year = ""; month = ""; year = txtinvoD.Text.Substring(6, 4); day = txtinvoD.Text.Substring(3, 2); month = txtinvoD.Text.Substring(0, 2); date = year + "-" + month + "-" + day; enteredDate = DateTime.Parse(date); _aObject.invoiceDate = enteredDate; } else { _aObject.invoiceDate = null; } if (_AssetsC.UpdateAsset(_aObject) == 1) { //Add change _changeA = new ChangeAssets(); _changeA.idAssetsfk = _aSearch.IdAssets; _changeA.idLocationfkch = _aSearch.idLocationfk; _changeA.idResponsiblefkch = _aSearch.idResponsiblefk; _changeA.pedimento = _aSearch.pedimento; _changeA.codePedimento = _aSearch.codePedimento; _changeA.visible = _aSearch.visible; _changeA.dateChange = DateTime.Now; _changeA.notes = _aSearch.notes; _changeA.invoice = _aSearch.invoice; _changeA.PO = _aSearch.PO; _changeA.provider = _aSearch.provider; _changeA.owner = _aSearch.owner; if (txtinvoD.Text != "") { _changeA.invoiceDate = _aObject.invoiceDate; } else { _changeA.invoiceDate = null; } if (_ChangeAC.AddChangeAsset(_changeA) == 1) { Clear(); MessageBox.Show("Información Actualizada.", "Operación exitosa.", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Error: En el momento de ACTUALIZAR en la base de datos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("ERROR 1: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int AddChangeAsset(ChangeAssets ChangeAE) { return(_changeAC.AddChangeAsset(ChangeAE)); }