private void cbCustomer_EditValueChanged(object sender, EventArgs e) { if (cbCustomer.EditValue != null) { bdgState.DataSource = state.Fetch("ORDER BY symbol"); antts ant = antts.SingleOrDefault("WHERE customer_id=@0", Convert.ToInt64(cbCustomer.EditValue)); if (ant == null) { ant = new antts(); } bdgAntt.DataSource = ant; pnControls.Enabled = true; btnSave.Enabled = true; if (ant.id > 0) { IsNew = false; } else { IsNew = true; } } else { bdgAntt.DataSource = null; pnControls.Enabled = false; btnSave.Enabled = false; } }
internal static bool NumberRntrcUnique(antts an) { try { int count; var s = TruckSystemRepo.GetInstance().ExecuteScalar <string> ("SELECT COUNT(id) FROM antts WHERE rntrc=@0", an.rntrc); if (s.Equals(DBNull.Value) || String.IsNullOrEmpty(s)) { count = 0; } else { count = Convert.ToInt32(s); } if (count == 0) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!Singleton.autenticateAdmin()) { return; } try { customer c = (customer)bdgBusiness.Current; antts a = antts.SingleOrDefault("WHERE customer_id = @0", c.id); if (a == null) { XtraMessageBox.Show("CNPJ/CPF selecionado nao contem ANTT cadastrada, verifique!"); return; } DialogResult dr = XtraMessageBox.Show(String.Format("Confirma adicionar/alterar {0} para o tipo Empresa Administradora?", c.corporate_name), "Confirmação", MessageBoxButtons.YesNo); if (dr == DialogResult.No) { return; } DialogResult rs = XtraMessageBox.Show("Essa alteração não podera ser desfeita por nenhum administrador," + " \napenas pela equipe técnica após analise do banco de dados.\nPodendo gerar custos adicionais!\n Deseja continuar?", "Confirmação", MessageBoxButtons.YesNo); if (rs == DialogResult.No) { return; } if (c == null) { return; } c.is_business = true; c.Save(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { XtraMessageBox.Show("Ocoreu um erro.\n\n" + ex.Message); this.DialogResult = DialogResult.Cancel; this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { if (!validator.Validate()) { return; } try { SplashScreenManager.ShowForm(null, typeof(PleaseWaitForm), false, false, false); antts an = (antts)bdgAntt.Current; an.customer_id = Convert.ToInt64(cbCustomer.EditValue); if (IsNew) { if (!Validations.Unique.NumberRntrcUnique(an)) { antts a = antts.SingleOrDefault("WHERE rntrc=@0", an.rntrc); customer c = customer.SingleOrDefault(a.customer_id); SplashScreenManager.CloseForm(false); XtraMessageBox.Show(String.Format("Rntrc já cadastrado!\nEm nome de {0} - {1}", c.corporate_name, c.document)); return; } } Console.WriteLine(an.customer_id); an.Save(); } catch (Exception ex) { XtraMessageBox.Show(String.Format("Ocorre um erro:\n{0}\n{1}", ex.Message, ex.InnerException)); } finally { SplashScreenManager.CloseForm(false); } if (this.MessageToSave("ANTT/RNTRC")) { desk.AddTabAndCloseCurrent(new AnttForm(), "Gerenciar ANTT", false); } }
private void cbCustomer_EditValueChanged(object sender, EventArgs e) { if(cbCustomer.EditValue != null) { bdgState.DataSource = state.Fetch("ORDER BY symbol"); antts ant = antts.SingleOrDefault("WHERE customer_id=@0", Convert.ToInt64(cbCustomer.EditValue)); if (ant == null) ant = new antts(); bdgAntt.DataSource = ant; pnControls.Enabled = true; btnSave.Enabled = true; if (ant.id > 0) IsNew = false; else IsNew = true; } else { bdgAntt.DataSource = null; pnControls.Enabled = false; btnSave.Enabled = false; } }
internal static bool NumberRntrcUnique(antts an) { try { int count; var s = TruckSystemRepo.GetInstance().ExecuteScalar<string> ("SELECT COUNT(id) FROM antts WHERE rntrc=@0", an.rntrc); if (s.Equals(DBNull.Value) || String.IsNullOrEmpty(s)) count = 0; else count = Convert.ToInt32(s); if (count == 0) return true; else return false; } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } }