public bool Delete(string empresaid, tb_sys_local BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbSysLocal_DELETE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public DataSet GetAll(string empresaid, tb_sys_local BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbSysLocal_SEARCH", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@localname", SqlDbType.VarChar, 50).Value = BE.localname; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public DataSet GenCodigo(string empresaid, tb_sys_local BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTb60GenNewItem_Local", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private string get_LocalName(string dominioid, string moduloid, string local) { sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); DataTable DT = new DataTable(); try { DT = BL.GetOne(EmpresaID, dominioid, moduloid, local).Tables[0]; return fungen.RemoveAccentsWithRegEx(DT.Rows[0]["localname"].ToString()); } catch (Exception ex) { return "Error"; } }
public bool Update(string empresaid, tb_sys_local BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbSysLocal_UPDATE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid; cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@localname", SqlDbType.VarChar, 50).Value = BE.localname; cmd.Parameters.Add("@localdirec", SqlDbType.VarChar, 70).Value = BE.localdirec; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte; cmd.Parameters.Add("@direcnume", SqlDbType.Char, 3).Value = BE.direcnume; cmd.Parameters.Add("@nmruc", SqlDbType.Char, 11).Value = BE.nmruc; cmd.Parameters.Add("@ctactename", SqlDbType.Char, 70).Value = BE.ctactename; cmd.Parameters.Add("@canalventaid", SqlDbType.Char, 3).Value = BE.canalventaid; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; cmd.Parameters.Add("@estabsunat", SqlDbType.Char, 4).Value = BE.estabsunat; cmd.Parameters.Add("@email", SqlDbType.VarChar, 50).Value = BE.email; cmd.Parameters.Add("@telef", SqlDbType.VarChar, 30).Value = BE.telf; cmd.Parameters.Add("@rpc", SqlDbType.VarChar, 30).Value = BE.rpc; //cmd.Parameters.Add("@perimeslocal", SqlDbType.Bit).Value = BE.perimeslocal; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void Insert() { try { if (dominioid.Text == "") { MessageBox.Show("Ingrese Código de Dominio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (moduloid.Text == "") { MessageBox.Show("Ingrese Código de modulo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //else if (direcnume.Text == "") //{ // MessageBox.Show("Ingrese Codigo de Local", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} else { sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); BE.dominioid = dominioid.Text.Trim(); BE.moduloid = moduloid.Text.Trim(); BE.local = item.Text.ToString(); BE.localname = localname.Text.ToString(); BE.usuar = VariablesPublicas.Usuar.Trim().ToString(); BE.ctacte = ctacte.Text.ToString(); BE.direcnume = direcnume.Text.ToString(); BE.nmruc = xNmruc.ToString(); BE.localdirec = xLocalDirec.ToString(); BE.ctactename = ctactename.Text.ToString(); BE.canalventaid = canalventaid.Text.ToString(); BE.status = "0"; // Informacion if (email_bien_escrito(email.Text.ToString())) { BE.email = email.Text.ToString(); } else { MessageBox.Show("Correo en Formato Incorrecto"); return; } BE.rpc = rpc.Text.ToString(); BE.telf = telf.Text.ToString(); BE.estabsunat = estabsunat.Text.ToString(); if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos grabados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Delete() { try { if (dominioid.Text.Trim().Length != 2) { MessageBox.Show("Ingrese Código de Dominio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (item.Text.Trim().Length != 4) { MessageBox.Show("Ingrese Código de modulo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); BE.dominioid = dominioid.Text.Trim(); BE.moduloid = moduloid.Text.Trim(); BE.local = item.Text.ToString(); if (BL.Delete(EmpresaID, BE)) { SEGURIDAD_LOG("E"); MessageBox.Show("Datos Eliminado correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); NIVEL_FORMS(); data_Tablamodulo(); limpiar_documento(); form_bloqueado(false); btn_nuevo.Enabled = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void data_Tablamodulo() { try { if (Tablamodulo != null) Tablamodulo.Rows.Clear(); sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); BE.dominioid = dominio.ToString(); BE.moduloid = modulo.ToString(); ; Tablamodulo = BL.GetAll(EmpresaID, BE).Tables[0]; if (Tablamodulo.Rows.Count > 0) { btn_imprimir.Enabled = true; dgb_local.DataSource = Tablamodulo; dgb_local.Rows[0].Selected = false; dgb_local.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ctacte_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F1) { AyudaCliente(""); // Despues de Que Vuelva del F1 ValidaCliente(); sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); DataTable dt = new DataTable(); BE.ctacte = ctacte.Text.ToString(); dt = BL.GenCodigo(EmpresaID, BE).Tables[0]; item.Text = dt.Rows[0]["item"].ToString().PadLeft(3, '0'); direcnume.Focus(); } if (e.KeyCode == Keys.Enter) { // Primero Validar ValidaCliente(); sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); DataTable dt = new DataTable(); BE.ctacte = ctacte.Text.ToString(); dt = BL.GenCodigo(EmpresaID, BE).Tables[0]; item.Text = dt.Rows[0]["item"].ToString().PadLeft(3, '0'); direcnume.Focus(); } }
private void cboLocal_SelectedIndexChanged(object sender, EventArgs e) { if (cboLocal.SelectedIndex != -1) { get_constantesGen(cboDominioID.SelectedValue.ToString(), cboModuloID.SelectedValue.ToString(), cboLocal.SelectedValue.ToString()); } var BE = new tb_sys_local(); BE.moduloid = cboModuloID.SelectedValue.ToString(); BE.dominioid = cboDominioID.SelectedValue.ToString(); BE.local = cboLocal.SelectedValue.ToString(); try { var BL = new sys_localBL(); var dt2 = new DataTable(); var empresaid = string.Empty; if (Equivalencias.Left(cboEmpresa.Text, 2) == "[0") { empresaid = "01"; } else { empresaid = Equivalencias.Left(cboEmpresa.Text, 2); } dt2 = BL.GetAll(empresaid, BE).Tables[0]; if (dt2.Rows.Count > 0) { _localname = dt2.Rows[0]["localname"].ToString(); _localfeuiv = Convert.ToDateTime(dt2.Rows[0]["localfeuiv"]); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void get_dominio_modulo_local(string dominioid, string moduloid) { if (moduloid.ToString().Length == 4 && moduloid.ToString() != "0000") { var BL = new sys_localBL(); var BE = new tb_sys_local(); BE.dominioid = dominioid; BE.moduloid = moduloid; var dt = new DataTable(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { localdes.DataSource = dt; localdes.ValueMember = "local"; localdes.DisplayMember = "localname"; } } }
private void data_cbo_localdes(String dominioid, String moduloid) { try { var BL = new sys_localBL(); var BE = new tb_sys_local(); BE.dominioid = dominioid; BE.moduloid = moduloid; var dt = new DataTable(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { VariablesPublicas.localdirec = dt.Rows[0]["localdirec"].ToString(); VariablesPublicas.telef = dt.Rows[0]["telef"].ToString(); } localdes.DataSource = dt; localdes.ValueMember = "local"; localdes.DisplayMember = "localname"; localdes.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void StatusBar() { lblUsuario.Text = VariablesPublicas.Nombr; lblCompany.Text = VariablesPublicas.EmpresaName; lblPeriodo.Text = perianio; //VariablesPublicas.perianio; var BL2 = new sys_localBL(); var BE2 = new tb_sys_local(); var dt2 = new DataTable(); BE2.dominioid = dominioid; // VariablesPublicas.Dominioid.ToString(); BE2.moduloid = moduloid; //VariablesPublicas.Moduloid.ToString(); BE2.local = local; //VariablesPublicas.Local.ToString(); dt2 = BL2.GetAll(VariablesPublicas.EmpresaID, BE2).Tables[0]; if (dt2.Rows.Count > 0) { var xxmesid = string.Empty; if (Convert.ToBoolean(dt2.Rows[0]["perimeslocal"])) { xxmesid = perimes; lblncaja.Text = _cajanume.ToString(); } else { xxmesid = perimes; //VariablesPublicas.perimes.ToString(); lblncaja.Text = _cajanume.ToString(); } //var BL = new tb_co_mesesBL(); //var dt = new DataTable(); //dt = BL.GetOne(VariablesPublicas.EmpresaID, xxmesid.ToString()).Tables[0]; //if (dt.Rows.Count > 0) //{ // lblperimes.Text = dt.Rows[0]["mesname"].ToString(); //} } //lblalmacen.Text = VariablesPublicas.EmpresaTipo; lblalmacen.Text = moduloname; lblVersion.Text = ProductVersion; TituloForm = "ERP - Bapsoft.Net - " + moduloname + " - "; //Text = ((TituloForm + lblCompany.Text + " »» LOCAL »» " + VariablesPublicas.nombrelocal.ToString())); Text = ((TituloForm + lblCompany.Text + " »» LOCAL »» " + localname)); }
private void _ManejaListPrec() { var BL = new sys_localBL(); var BE = new tb_sys_local(); var dt = new DataTable(); BE.dominioid = dominio.ToString(); BE.moduloid = modulo.ToString(); BE.local = local.ToString(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { ManejaListPrec = Convert.ToBoolean(dt.Rows[0]["manejalistprec"].ToString()); } }
private void get_val_fechadoc() { try { var BL = new constantesgeneralesBL(); var dt = new DataTable(); dt = BL.GetOne(EmpresaID, dominio, modulo, local).Tables[0]; if (dt.Rows.Count > 0) { perianio = dt.Rows[0]["perianio"].ToString().Trim(); var BL2 = new sys_localBL(); var BE2 = new tb_sys_local(); var dt2 = new DataTable(); BE2.dominioid = dominio.ToString(); BE2.moduloid = modulo.ToString(); ; BE2.local = local.ToString(); dt2 = BL2.GetAll(VariablesPublicas.EmpresaID, BE2).Tables[0]; if (dt2.Rows.Count > 0) { // Lo que esta comentado es para validar con el perimes del => BapConfig.cfg //if (Convert.ToBoolean(dt2.Rows[0]["perimeslocal"])) //{ // perimes = _perimes; //} //else //{ perimes = dt.Rows[0]["perimes"].ToString().Trim(); //} } if (dt.Rows[0]["fechadocedit"].ToString().Trim().Length > 0) { fechadocedit = Convert.ToBoolean(dt.Rows[0]["fechadocedit"]); } } var fechaactual = DateTime.Today; var fechaperiodo = Convert.ToDateTime("01" + "/" + perimes + "/" + perianio); if (fechadocedit) { var primerdia = new DateTime(fechaperiodo.Year, fechaperiodo.Month, 1); var ultimodia = primerdia.AddMonths(1).AddDays(-1); if (fechaactual.Day <= ultimodia.Day) { fechdoc.Value = Convert.ToDateTime(fechaactual.Day + "/" + perimes + "/" + perianio); } else { fechdoc.Value = Convert.ToDateTime(ultimodia.Day + "/" + perimes + "/" + perianio); } fechdoc.MaxDate = ultimodia; fechdoc.MinDate = primerdia; } else { if (fechaactual.Month == fechaperiodo.Month && fechaactual.Year == fechaperiodo.Year) { fechdoc.Value = fechaactual; } else { MessageBox.Show("Actualizar a periodo actual en tabla constantes generales !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); statusDoc = false; } } get_tipocambio(fechdoc.Text); get_tipimptoid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); statusDoc = false; } }
private void cboLocal_SelectedIndexChanged(object sender, EventArgs e) { if (cboLocal.SelectedIndex != -1) { get_constantesGen(cboDominioID.SelectedValue.ToString(), cboModuloID.SelectedValue.ToString(), cboLocal.SelectedValue.ToString()); } var BE = new tb_sys_local(); BE.moduloid = cboModuloID.SelectedValue.ToString(); BE.dominioid = cboDominioID.SelectedValue.ToString(); BE.local = cboLocal.SelectedValue.ToString(); try { var BL = new sys_localBL(); var dt2 = new DataTable(); var empresaid = string.Empty; empresaid = VariablesPublicas.EmpresaID; dt2 = BL.GetAll(empresaid, BE).Tables[0]; if (dt2.Rows.Count > 0) { VariablesPublicas.EmpresaEstablec = dt2.Rows[0]["localname"].ToString(); VariablesPublicas.localfeuiv = dt2.Rows[0]["localfeuiv"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ValidaLocal() { if (xlocal.Text.Trim().Length > 0) { var BL = new sys_localBL(); var BE = new tb_sys_local(); var dt = new DataTable(); BE.dominioid = dominioid.Text.Trim(); BE.moduloid = moduloid.Text.Trim(); BE.local = xlocal.Text.Trim().PadLeft(3, '0'); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { xlocal.Text = dt.Rows[0]["local"].ToString().Trim(); localname.Text = dt.Rows[0]["localname"].ToString().Trim(); tipodoc.Enabled = true; tipodoc.Focus(); } else { xlocal.Text = string.Empty; localname.Text = string.Empty; xlocal.Enabled = true; } } else { xlocal.Text = string.Empty; localname.Text = string.Empty; xlocal.Enabled = true; } }
private void btn_agregar_Click(object sender, EventArgs e) { direcnume.Text = ""; localname.Text = ""; direcnume.Enabled = true; canalventaid.Enabled = true; btn_cancelar.Enabled = true; btn_nuevo.Enabled = false; btn_editar.Enabled = false; sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); DataTable dt = new DataTable(); if (ctacte.Text == "") { MessageBox.Show("No Existe la Cuenta Corriente Para Generar el Item !!!"); return; } BE.ctacte = ctacte.Text.ToString(); dt = BL.GenCodigo(EmpresaID, BE).Tables[0]; item.Text = dt.Rows[0]["item"].ToString().PadLeft(3, '0'); ssModo = "NEW"; btn_grabar.Enabled = true; estabsunat.Enabled = true; telf.Enabled = true; rpc.Enabled = true; email.Enabled = true; direcnume.Focus(); }
private void btn_busqueda_Click(object sender, EventArgs e) { sys_localBL BL = new sys_localBL(); tb_sys_local BE = new tb_sys_local(); DataTable dt = new DataTable(); //BE.dominioid = dominioid.Text.Trim(); //BE.moduloid = moduloid.Text.Trim(); BE.localname = txt_busqueda.Text.ToString(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { dgb_local.DataSource = dt; } }
private void ValidaLocal(String NameLocal) { if (NameLocal.Trim().Length > 0) { var BL = new sys_localBL(); var BE = new tb_sys_local(); var dt = new DataTable(); BE.dominioid = dominio.ToString().Trim(); BE.moduloid = modulo.ToString().Trim(); BE.local = NameLocal.Trim().ToString(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { loc_id.Text = dt.Rows[0]["local"].ToString().Trim(); loc_name.Text = dt.Rows[0]["localname"].ToString().Trim(); } else { loc_id.Text = string.Empty; loc_name.Text = string.Empty; } } }
private void get_val_fechadoc() { try { constantesgeneralesBL BL = new constantesgeneralesBL(); tb_constantesgenerales BE = new tb_constantesgenerales(); DataTable dt = new DataTable(); dt = BL.GetOne(EmpresaID, dominio, modulo, local).Tables[0]; if (dt.Rows.Count > 0) { perianio = dt.Rows[0]["perianio"].ToString().Trim(); // Vamos Obtener el Check de Perimes Local Para Usar el Perimes de Constanantes o del Bapconfig var BL2 = new sys_localBL(); var BE2 = new tb_sys_local(); DataTable dt2 = new DataTable(); BE2.dominioid = dominio.ToString(); BE2.moduloid = modulo.ToString(); ; BE2.local = local.ToString(); dt2 = BL2.GetAll(VariablesPublicas.EmpresaID, BE2).Tables[0]; if (dt2.Rows.Count > 0) { if (Convert.ToBoolean(dt2.Rows[0]["perimeslocal"])) { // Hemos Fijado el Perimes en BapConfig perimes = _perimes; } else { // Ponemos el Perimes de Constantes Generales perimes = dt.Rows[0]["perimes"].ToString().Trim(); } } if (dt.Rows[0]["fechadocedit"].ToString().Trim().Length > 0) { fechadocedit = Convert.ToBoolean(dt.Rows[0]["fechadocedit"]); } } DateTime fechaactual = DateTime.Today; DateTime fechaperiodo = Convert.ToDateTime("01" + "/" + perimes + "/" + perianio); if (fechadocedit) { //DateTime primerdia = new DateTime(fechaperiodo.Year, fechaperiodo.Month, 1); //DateTime ultimodia = primerdia.AddMonths(1).AddDays(-1); //if (fechaactual.Day <= ultimodia.Day) //{ // fechdoc.Value = Convert.ToDateTime(fechaactual.Day + "/" + perimes + "/" + perianio); //} //else //{ // fechdoc.Value = Convert.ToDateTime(ultimodia.Day + "/" + perimes + "/" + perianio); //} //fechdoc.MaxDate = ultimodia; //fechdoc.MinDate = primerdia; } else { if (fechaactual.Month == fechaperiodo.Month && fechaactual.Year == fechaperiodo.Year) { fechdoc.Value = fechaactual; //fechdoc.Enabled = false; } else { MessageBox.Show("Actualizar a Periodo Actual en Tabla Constantes Generales !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); statusDoc = false; } } get_tipocambio(fechdoc.Text); get_tipimptoid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); statusDoc = false; } }