0% found this document useful (0 votes)
17 views

public String Cedularuc (Get Set )

The document contains code for a Windows form application that allows users to enter and save data related to forest management. It includes classes to store company, logging area, and logging order data. The form loads dropdowns with existing company, logging area, and order data. It validates user input and saves new records to a database upon form submission. Validation includes checks for empty fields and correct data formats. Saved records include details like company, date, logged area, and supervisor information.

Uploaded by

Eli4511
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

public String Cedularuc (Get Set )

The document contains code for a Windows form application that allows users to enter and save data related to forest management. It includes classes to store company, logging area, and logging order data. The form loads dropdowns with existing company, logging area, and order data. It validates user input and saves new records to a database upon form submission. Validation includes checks for empty fields and correct data formats. Saved records include details like company, date, logged area, and supervisor information.

Uploaded by

Eli4511
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using using using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Globalization; System.Data.SqlClient;

namespace Quema { public partial class Form1 : Form { DBCAMPOEntities dc = new DBCAMPOEntities(); public Form1() { InitializeComponent(); } private class TmpCia { public String CodCia { get; set; } public String NomCia { get; set; } //public String CedulaRUC { get; set; } } private class TmpCantero { public String CodCantero { get; set; } public int areaTotal { get; set; } } private void Form1_Load(object sender, EventArgs e) { var xx = (from p in dc.TBControl where p.NumZafra >= 113 select p.NumZafra).ToList(); this.cmbNumZafra.DataSource = xx; TBCabGuiQue TB = new TBCabGuiQue(); List<TmpCia> WLstCias = new List<TmpCia>(); TmpCia WCia; var yy = (from p in dc.TBCias select new { p.CodCia, NomCia2 = p.CodCia + "-" + p.NomCia}); foreach (var item in yy) { WCia = new TmpCia(); WCia.CodCia = item.CodCia; WCia.NomCia = item.NomCia2; // WCia.CedulaRUC = item.CedulaRUC; WLstCias.Add(WCia); } this.cmbCompaia.DataSource = WLstCias; this.cmbCompaia.DisplayMember = "NomCia"; this.cmbCompaia.ValueMember = "CodCia"; this.cmbCompaia.SelectedIndex = 0; TBSecciones TS = new TBSecciones(); var sec = (from p in dc.TBSecciones where p.Planificar == "S" orderby p.CodSeccion select p.CodSeccion ).ToList(); this.cmbseccion.DataSource = sec; var sec2 = (from p in dc.TBSecciones where p.Planificar == "S" orderby p.CodSeccion select new { p.CodSeccion, p.DescSecc, p.Planificar, p.TipCorte } ).ToList(); this.dataGridView1.DataSource = sec2; }

private void txtNumOrden_Validating(object sender, CancelEventArgs e) { e.Cancel = false; String WTexto = this.txtNumOrden.Text.ToString(); if (WTexto.Trim() == "") { e.Cancel = true; MessageBox.Show("debe ingresar ot..."); return; } var Wot = (from p in dc.TBCabOrden where p.NumOrden == WTexto select p).ToList(); if (Wot.Count <= 0) { e.Cancel = true ; MessageBox.Show("ot no existe"); return; } this.lblAreaTotal.Text = Wot[0].TotUndPlan.ToString(); } private void btnGraba_Click(object sender, EventArgs e) { ////////////////////////////// //validar espacios en Blanco// ///////////////////////////// String WZz = this.MskFecha.Text; String x = this.cmbCompaia.SelectedValue.ToString(); TmpCia WTmpCia = (TmpCia) this.cmbCompaia.SelectedItem; //x = WTmpCia.CedulaRUC; String WTexto = this.txtNumOrden.Text.ToString(); if (WTexto.Trim() == "") { MessageBox.Show("N de Orden en Blanco", this.Text, MessageBoxButtons.OK); return; } String ZTexto = this.txtquemar.Text.ToString(); if (ZTexto.Trim() == "") { MessageBox.Show("Hectareas a Quemar en Blanco..", this.Text, MessageBoxButtons.OK); return; } var valorsel = cmbCantero.SelectedValue.ToString(); int NumZafra = Convert.ToInt32(this.cmbNumZafra.Text); var codcia = this.cmbCompaia.SelectedValue.ToString(); float canhas =0; float.TryParse(this.txtquemar.Text.ToString(), out canhas); TBCabGuiQue WCabGuiQue = new TBCabGuiQue(); WCabGuiQue.NumZafra = NumZafra; WCabGuiQue.GuiQuema = this.txtNumGui.Text.ToString(); WCabGuiQue.CodCia = codcia; WCabGuiQue.NumCantero = valorsel; WCabGuiQue.CodSeccion = this.cmbseccion.Text.ToString();

WCabGuiQue.FecQuema = Convert.ToDateTime(this.MskFecha.Text); //WCabGuiQue.CanHas = canhas; //WCabGuiQue.NumOrden = this.txtNumOrden.Text.ToString(); dc.TBCabGuiQue.Add(WCabGuiQue); try { dc.SaveChanges(); MessageBox.Show("Registro grabado exitosamente!!.."); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //WTransaccion.Dispose(); string WmsgErr = Clases.CtrolErrores.FEntidadesValidaErr(ex); MessageBox.Show(WmsgErr); throw; } catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyExcep tion ex) { //WTransaccion.Dispose(); string WMsgErr = Clases.CtrolErrores.FEntidadesUpdateErr(ex); MessageBox.Show(WMsgErr); throw; } catch (System.Data.Entity.Infrastructure.DbUpdateException ex) { //WTransaccion.Dispose(); string WMsgErr = Clases.CtrolErrores.FEntidadesUpdateErr(ex); MessageBox.Show(WMsgErr); throw; } catch (Exception) { //WTransaccion.Dispose(); throw; } } private void button1_Click(object sender, EventArgs e) { this.Close(); } private void MskFecha_Validated(object sender, EventArgs e) { DateTime fecha; if (!DateTime.TryParse(MskFecha.Text, out fecha) && MskFecha.MaskCompleted == false) { MessageBox.Show("Fecha incorrecta"); return; } } private void mskHora_Validated(object sender, EventArgs e) { DateTime hora; if (!DateTime.TryParse(mskHora.Text, out hora) && mskHora.MaskCompleted == false) { MessageBox.Show("Hora incorrecta!!"); return; } }

private void cmbCompaia_SelectedIndexChanged(object sender, EventArgs e) { String WCia = this.cmbCompaia.SelectedValue.ToString(); var WLstCantero = (from p in dc.TBCantero where p.CodCia == WCia select new { Cantero = p.NumCantero}).ToList(); this.cmbCantero.DataSource = WLstCantero; this.cmbCantero.DisplayMember = "DescCantero"; this.cmbCantero.ValueMember = "Cantero"; this.cmbCantero.Visible = true; } private void txtquemar_Validating(object sender, CancelEventArgs e) { double xx ; if (!Double.TryParse(this.txtquemar.Text.ToString(), out xx)) { MessageBox.Show("Debe ingresar solo numeros"); } } private void txtNumGui_Validating(object sender, CancelEventArgs e) { int xx; if (!int.TryParse(this.txtNumGui.Text.ToString(), out xx)) { MessageBox.Show("Debe ingresar solo numeros"); } } private void cmbCantero_SelectedIndexChanged(object sender, EventArgs e) { int WZafra = 129; String WCodCia = this.cmbCompaia.SelectedValue.ToString(); String WNumCantero = this.cmbCantero.SelectedValue.ToString(); double Wtotal = 0; var WCanteroSuma = (from p in dc.TBCabGuiQue where p.NumZafra == WZafra && p.CodCia == WCodCia && p.NumCantero == WNumCantero select p.CanHas).ToList(); //Wtotal = WCanteroSuma.Sum(x => x.Value); //this.lblHas.Text = Wtotal.ToString(); String WCodigoCia = this.cmbCompaia.SelectedValue.ToString(); String WNumeroCantero = this.cmbCantero.SelectedValue.ToString(); double WtotalArea = 0; var WArea = (from p in dc.TBCantero where p.CodCia == WCodigoCia && p.NumCantero == WNumeroCantero select p.AreTotal).ToList(); //WtotalArea = WArea.Sum(x => x.Value); //this.lblAreaTotal.Text = WArea.ToString(); } } }

You might also like