Exemplo n.º 1
0
        private void MyCmdGuardar_Click()
        {
            try
            {
                if ((string.IsNullOrEmpty(txtArea0)) || (string.IsNullOrEmpty(txtArea1)) || (string.IsNullOrEmpty(txtArea2)))
                {
                    return;
                }

                string myArea               = string.Empty;
                string myDesc               = string.Empty;
                string myPrecintos          = string.Empty;
                string myElectivePositionID = "0";
                string myDemarcationID      = "0";
                string myWhere              = string.Empty;

                myWhere = _IsInsert == false?cbArea_Item.Substring(0, 4) : "";

                myArea = string.Concat(txtArea0, txtArea1);
                myDesc = txtArea2;

                foreach (Precintos p in lsValidPrecints.ToList())
                {
                    myPrecintos += p.ToString().Split('-')[0].Trim() + "|";
                }

                bool myUpDate = false;

                using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand()
                {
                    DBCnnStr = _DBEndososCnnStr
                })
                {
                    myUpDate = mySqlExe.MyChangeArea(_IsInsert, myArea, myDesc, myPrecintos, myElectivePositionID, myDemarcationID, myWhere);

                    if (myUpDate)
                    {
                        _MyAreasTable = mySqlExe.MyGetAreas(false);
                        cbArea.Clear();
                        foreach (DataRow row in _MyAreasTable.Rows)
                        {
                            cbArea.Add(row[0].ToString());
                        }
                    }
                }

                if (!myUpDate)
                {
                    throw new Exception("Error en la Base de Data");
                }

                MyReset();
                MessageBox.Show("Done...", "Save", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        private void MyCmdDelete_Click()
        {
            try
            {
                if ((string.IsNullOrEmpty(txtArea0)) || (string.IsNullOrEmpty(txtArea1)) || (string.IsNullOrEmpty(txtArea2)))
                {
                    return;
                }

                var response = MessageBox.Show("!!!Do you really want to Delete this Area?\r\n" + cbArea_Item, "Deleting...", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                if (response == MessageBoxResult.No)
                {
                    return;
                }


                string myWhere = string.Empty;
                myWhere = cbArea_Item.Substring(0, 4);
                bool myDelete = false;

                using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand()
                {
                    DBCnnStr = _DBEndososCnnStr
                })
                {
                    myDelete = mySqlExe.MyDeleteArea(myWhere);

                    if (myDelete)
                    {
                        _MyAreasTable = mySqlExe.MyGetAreas(false);
                        cbArea.Clear();
                        foreach (DataRow row in _MyAreasTable.Rows)
                        {
                            cbArea.Add(row[0].ToString());
                        }
                    }
                }

                if (!myDelete)
                {
                    throw new Exception("Error en la Base de Data");
                }

                MessageBox.Show("Done...", "Delete", MessageBoxButton.OK, MessageBoxImage.Information);

                MyReset();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 3
0
        private void MyInitWindow()
        {
            try
            {
                string myBorderBrush = ConfigurationManager.AppSettings["BorderBrush"];

                if (myBorderBrush != null && myBorderBrush.Trim().Length > 0)
                {
                    Type  t = typeof(Brushes);
                    Brush b = (Brush)t.GetProperty(myBorderBrush).GetValue(null, null);
                    BorderBrush = b;
                }
                else
                {
                    BorderBrush = Brushes.Black;
                }


                cbPartidos.Clear();
                cbArea.Clear();

                using (SqlExcuteCommand get = new SqlExcuteCommand()
                {
                    DBCnnStr = DBEndososCnnStr
                })
                {
                    _MyAreasTable = get.MyGetAreas(true);

                    foreach (DataRow row in _MyAreasTable.Rows)
                    {
                        Area myArea = new Area();

                        myArea.AreaKey            = row["Area"].ToString();
                        myArea.Precintos          = row["Precintos"].ToString();
                        myArea.Desc               = row["Desc"].ToString();
                        myArea.ElectivePositionID = row["ElectivePositionID"].ToString();
                        myArea.DemarcationID      = row["DemarcationID"].ToString();

                        cbArea.Add(myArea);
                    }

                    _MyPartidosTable = get.MyGetPartidos(WhatIsModo);

                    foreach (DataRow row in _MyPartidosTable.Rows)
                    {
                        Partidos mypartido = new Partidos();
                        mypartido.Id         = (int)row["Id"];
                        mypartido.PartidoKey = row["Partido"].ToString();
                        mypartido.Desc       = row["Desc"].ToString();
                        mypartido.EndoReq    = (int)row["EndoReq"];
                        mypartido.Area       = row["Area"].ToString();
                        mypartido.Modo       = int.Parse(row["Modo"].ToString());


                        //"Aspirante = 1"
                        //"Partido = 2"

                        if (WhatIsModo == 1)
                        {
                            if (mypartido.Modo == 1)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                        else
                        {
                            if (mypartido.Modo == 2)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                    }
                }
                cbPartidos.Sort();
                MyReset();
            }
            catch (Exception ex)
            {
                MethodBase site = ex.TargetSite;
                MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 4
0
        private void MyInitWindow()
        {
            try
            {
                string myBorderBrush = ConfigurationManager.AppSettings["BorderBrush"];

                if (myBorderBrush != null && myBorderBrush.Trim().Length > 0)
                {
                    Type  t = typeof(Brushes);
                    Brush b = (Brush)t.GetProperty(myBorderBrush).GetValue(null, null);
                    BorderBrush = b;
                }
                else
                {
                    BorderBrush = Brushes.Black;
                }

                cbArea          = new ObservableCollection <string>();
                lsAllPrecints   = new ObservableCollection <Precintos>();
                lsValidPrecints = new ObservableCollection <Precintos>();
                cbArea_Item_Id  = -1;

                txtArea0 = "0";
                txtArea1 = "0";
                txtArea2 = string.Empty;

                IsEnabled_CmdAddAllPrec    = false;
                IsEnabled_CmdAddPrec       = false;
                IsEnabled_CmdRemovePrec    = false;
                IsEnabled_CmdRemoveAllPrec = false;

                IsEnabled_CmdEditar  = false;
                IsEnabled_CmdGuardar = false;
                IsEnabled_CmdDelete  = false;
                IsEnabled_cmdAnadir  = true;
                IsEnabled_CmdCancel  = false;
                IsEditable_cbArea    = false;

                IsEnabled_txtArea0 = false;
                IsEnabled_txtArea1 = false;
                IsEnabled_txtArea2 = false;

                IsEnabled_cbArea   = true;
                IsEnabled_CmdSalir = true;

                Visibility_cbArea   = Visibility.Visible;
                Visibility_txtArea0 = Visibility.Hidden;
                Visibility_txtArea1 = Visibility.Hidden;
                Visibility_txtArea2 = Visibility.Hidden;

                using (SqlExcuteCommand get = new SqlExcuteCommand()
                {
                    DBCnnStr = DBEndososCnnStr
                })
                {
                    _MyAreasTable = get.MyGetAreas(false);

                    foreach (DataRow row in _MyAreasTable.Rows)
                    {
                        cbArea.Add(row[0].ToString());
                    }

                    _MyPrecintosTable = get.MyGetPrecintos();

                    this.View.lsAll.ItemsSource   = lsAllPrecints;
                    this.View.lsValid.ItemsSource = lsValidPrecints;

                    MySetAllPrecinto(_MyPrecintosTable);
                }
            }
            catch (Exception ex)
            {
                MethodBase site = ex.TargetSite;
                MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void MyRefresh()
        {
            try
            {
                cbArea.Clear();
                cbPartidos.Clear();
                using (SqlExcuteCommand get = new SqlExcuteCommand()
                {
                    DBCnnStr = DBEndososCnnStr
                })
                {
                    _MyAreasTable = get.MyGetAreas(true);

                    foreach (DataRow row in _MyAreasTable.Rows)
                    {
                        Area myArea = new Area();

                        myArea.AreaKey            = row["Area"].ToString();
                        myArea.Precintos          = row["Precintos"].ToString();
                        myArea.Desc               = row["Desc"].ToString();
                        myArea.ElectivePositionID = row["ElectivePositionID"].ToString();
                        myArea.DemarcationID      = row["DemarcationID"].ToString();

                        cbArea.Add(myArea);
                    }
                    _MyPartidosTable = get.MyGetPartidos(WhatIsModo);

                    foreach (DataRow row in _MyPartidosTable.Rows)
                    {
                        Partidos mypartido = new Partidos();
                        mypartido.Id         = (int)row["Id"];
                        mypartido.PartidoKey = row["Partido"].ToString();
                        mypartido.Desc       = row["Desc"].ToString();
                        mypartido.EndoReq    = (int)row["EndoReq"];
                        mypartido.Area       = row["Area"].ToString();
                        mypartido.Modo       = int.Parse(row["Modo"].ToString());

                        //"Aspirante = 1"
                        //"Partido = 2"
                        if (WhatIsModo == 1)
                        {
                            if (mypartido.Modo == 1)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                        else
                        {
                            if (mypartido.Modo == 2)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                    }
                }
                cbPartidos.Sort();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }