private Collectable.Account AccountFromGrid(DataGridView dgv) { Collectable.Account account = new Collectable.Account(); account.DocId = int.Parse(dgv.CurrentRow.Cells["id_doco"].Value.ToString()); account.ApId = int.Parse(dgv.CurrentRow.Cells["ap_id"].Value.ToString()); account.DocDate = DateTime.Parse(dgv.CurrentRow.Cells["f_documento"].Value.ToString()); account.DueDate = DateTime.Parse(dgv.CurrentRow.Cells["f_vencimiento"].Value.ToString()); if (!string.Empty.Equals(dgv.CurrentRow.Cells["f_cobro"].Value.ToString())) { account.CollectDate = DateTime.Parse(dgv.CurrentRow.Cells["f_cobro"].Value.ToString()); } account.Serie = dgv.CurrentRow.Cells["serie_doco"].Value.ToString(); account.Folio = int.Parse(dgv.CurrentRow.Cells["folio_doco"].Value.ToString()); account.DocType = dgv.CurrentRow.Cells["tipo_documento"].Value.ToString(); account.CollectType = dgv.CurrentRow.Cells["tipo_cobro"].Value.ToString(); account.Amount = double.Parse(dgv.CurrentRow.Cells["facturado"].Value.ToString()); account.Balance = double.Parse(dgv.CurrentRow.Cells["saldo"].Value.ToString()); account.Currency = dgv.CurrentRow.Cells["moneda"].Value.ToString(); account.Note = dgv.CurrentRow.Cells["observaciones"].Value.ToString(); Collectable.Company company = new Collectable.Company(); company.Id = int.Parse(dgv.CurrentRow.Cells["id_cliente"].Value.ToString()); company.Code = dgv.CurrentRow.Cells["cd_cliente"].Value.ToString(); company.Name = dgv.CurrentRow.Cells["nombre_cliente"].Value.ToString(); company.AgentCode = dgv.CurrentRow.Cells["ruta"].Value.ToString(); company.PaymentDay = dgv.CurrentRow.Cells["dia_pago"].Value.ToString(); company.EnterpriseId = int.Parse(dgv.CurrentRow.Cells["id_empresa"].Value.ToString()); company.EnterprisePath = dgv.CurrentRow.Cells["ruta_e"].Value.ToString(); account.Company = company; return(account); }
private List <Collectable.Account> SelectedAdminId(DataGridView dgv) { List <Collectable.Account> selectedAdminId = new List <Collectable.Account>(); foreach (DataGridViewCell cell in dgv.SelectedCells) { DataGridViewRow selectedRow = dgv.Rows[cell.RowIndex]; int selectedId = int.Parse(selectedRow.Cells["ap_id"].Value.ToString()); int selectedPgDocId = int.Parse(selectedRow.Cells["id_doco"].Value.ToString()); string rutaEmpresa = selectedRow.Cells["ruta_e"].Value.ToString(); Collectable.Account pgDoco = new Collectable.Account(); pgDoco.ApId = selectedId; pgDoco.DocId = selectedPgDocId; Company co = new Company(); co.EnterprisePath = rutaEmpresa; pgDoco.Company = co; if (!selectedAdminId.Contains(pgDoco)) { selectedAdminId.Add(pgDoco); } } return(selectedAdminId); }
public void UpdateAccountById(Collectable.Account adminPaqAccount) { using (NpgsqlConnection conn = new NpgsqlConnection(ConnString)) { conn.Open(); string sqlString = "UPDATE ctrl_cuenta " + "SET F_COBRO = @f_cobro, " + "TIPO_COBRO = @tipo_cobro, " + "OBSERVACIONES = @observaciones, " + "TS_DESCARGADO = CURRENT_TIMESTAMP " + "WHERE ID_DOCO = @id"; NpgsqlCommand cmd = new NpgsqlCommand(sqlString, conn); cmd.Parameters.Add("@f_cobro", NpgsqlTypes.NpgsqlDbType.Date); cmd.Parameters.Add("@tipo_cobro", NpgsqlTypes.NpgsqlDbType.Varchar, 100); cmd.Parameters.Add("@observaciones", NpgsqlTypes.NpgsqlDbType.Varchar, 250); cmd.Parameters.Add("@id", NpgsqlTypes.NpgsqlDbType.Integer); cmd.Parameters["@f_cobro"].Value = adminPaqAccount.CollectDate; cmd.Parameters["@tipo_cobro"].Value = adminPaqAccount.CollectType; cmd.Parameters["@observaciones"].Value = adminPaqAccount.Note; cmd.Parameters["@id"].Value = adminPaqAccount.DocId; cmd.ExecuteNonQuery(); if (adminPaqAccount.CollectDate.Ticks == 0) { sqlString = "UPDATE ctrl_cuenta SET f_cobro = null where id_doco=@id"; cmd = new NpgsqlCommand(sqlString, conn); cmd.Parameters.Add("@id", NpgsqlTypes.NpgsqlDbType.Integer); cmd.Parameters["@id"].Value = adminPaqAccount.DocId; cmd.ExecuteNonQuery(); } sqlString = "INSERT INTO ctrl_seguimiento(id_movimiento, id_doco, descripcion) " + "VALUES(2, @documento, 'Cuenta actualizada en AdminPaq por el Gerente. FC:" + adminPaqAccount.CollectDate.ToShortDateString() + ";O:" + adminPaqAccount.Note + ";TC:" + adminPaqAccount.CollectType + ";');"; cmd = new NpgsqlCommand(sqlString, conn); cmd.Parameters.Add("@documento", NpgsqlTypes.NpgsqlDbType.Integer); cmd.Parameters["@documento"].Value = adminPaqAccount.DocId; try { cmd.ExecuteNonQuery(); } catch (Exception e) { conn.Close(); throw new Exception(UNEXISTING_DOCO_ERR); } conn.Close(); } }
private void SetCollectDate(DateTimePicker dtp, Collectable.Account account) { try { if (!dtp.Checked) { //18991230 DateTime dt = new DateTime(1899, 12, 30); api.SetCollectDate(account.ApId, dt, account.Company.EnterprisePath); dbAccount.SetCollectDate(account.DocId, dt); } else { api.SetCollectDate(account.ApId, dtp.Value, account.Company.EnterprisePath); dbAccount.SetCollectDate(account.DocId, dtp.Value); } } catch (Exception ex) { MessageBox.Show("No se pudo actualizar la fecha de cobro en AdminPaq para el folio: [" + account.Folio + "]. \n" + ex.Message, "Fecha de cobro no guardada", MessageBoxButtons.OK, MessageBoxIcon.Information); } }