Esempio n. 1
0
 private void Btnremoveequipment_Click(object sender, RoutedEventArgs e)
 {
     if (lbEquipments.Items.Count > 0)
     {
         if (lbEquipments.SelectedValue != null || lbEquipments.SelectedValue.ToString() != "")
         {
             string[] type = Regex.Split(lbEquipments.SelectedItem.ToString(), ": ");
             if (type.Length > 1)
             {
                 string           table            = "as_" + type[1].ToString().Split(' ')[0];
                 MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to delete?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);
                 if (messageBoxResult == MessageBoxResult.Yes)
                 {
                     string msg = EquipmentData.DeleteEquipment(table, type[0].ToString().Split(' ')[1]);
                     if (msg == "Executed")
                     {
                         lbEquipments.Items.RemoveAt(lbEquipments.SelectedIndex);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            string msg = string.Empty;

            if (Equipment.getEquipId == null)
            {
                string    query = "select top 1 id from as_sonnenschutz order by id desc";
                DataTable dt    = DataConnection.GetData(query);
                int       id    = 1;
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (dt.Rows[0][0].ToString() != "")
                    {
                        id = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                    }
                    query = "insert into as_sonnenschutz values(" + Application.Current.Properties["BuildingId"] + ",'" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')";
                    msg   = DataConnection.ExecuteQuery(query);
                }
                else if (dt != null && dt.Rows.Count >= 1)
                {
                    int status = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i][0].ToString() != "")
                        {
                            id     = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                            query  = "insert into as_sonnenschutz values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')";
                            msg    = DataConnection.ExecuteQuery(query);
                            status = 1;
                            break;
                        }
                    }
                    if (status == 0)
                    {
                        query = "insert into as_sonnenschutz values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')";
                        msg   = DataConnection.ExecuteQuery(query);
                    }
                }
                else
                {
                    query = "insert into as_sonnenschutz values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')";
                    msg   = DataConnection.ExecuteQuery(query);
                }
                if (msg == "Executed")
                {
                    query = "select top 1 id from as_sonnenschutz order by id desc";
                    dt    = DataConnection.GetData(query);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        UpdateChildGetSet     = true;
                        SelectChildTypeValues = "EquipId " + dt.Rows[0][0].ToString() + ": " + "sonnenschutz " + cbtype.SelectedValue + "," + cbLage.SelectedValue;
                        //var myWindow =
                        Window.GetWindow(this).Close();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter correct input values");
                }
            }
            else
            {
                string updatedcolumns = "sonnenschutztyp='" + cbtype.SelectedValue + "' , lage='" + cbLage.SelectedValue + "'";
                msg = EquipmentData.UpdateEquipment("as_sonnenschutz", updatedcolumns, Equipment.getEquipId);
                if (msg == "Executed")
                {
                    UpdateChildGetSet     = true;
                    SelectChildTypeValues = "EquipId " + Equipment.getEquipId + ": " + "sonnenschutz " + cbtype.SelectedValue + "," + cbLage.SelectedValue;
                    Window.GetWindow(this).Close();
                }
                else
                {
                    MessageBox.Show("Please enter correct input values");
                }
            }
        }
Esempio n. 3
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            string msg = string.Empty;

            if (Equipment.getEquipId == null)
            {
                string    query = "select top 1 id from as_tuer order by id desc";
                DataTable dt    = DataConnection.GetData(query);
                int       id    = 1;
                if (dt != null && dt.Rows.Count > 0)
                {
                    id    = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                    query = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')";
                    msg   = DataConnection.ExecuteQuery(query);
                }
                else if (dt != null && dt.Rows.Count >= 1)
                {
                    int status = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i][0].ToString() != "")
                        {
                            id     = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                            query  = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')";
                            msg    = DataConnection.ExecuteQuery(query);
                            status = 1;
                            break;
                        }
                    }
                    if (status == 0)
                    {
                        query = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')";
                        msg   = DataConnection.ExecuteQuery(query);
                    }
                }
                else
                {
                    query = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')";
                    msg   = DataConnection.ExecuteQuery(query);
                }
                if (msg == "Executed")
                {
                    query = "select top 1 id from as_tuer order by id desc";
                    dt    = DataConnection.GetData(query);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        UpdateChildGetSet     = true;
                        SelectChildTypeValues = "EquipId " + dt.Rows[0][0].ToString() + ": " + "tuer" + " (" + txtHohe.Text + "x" + txtBreite.Text + ")," + cbTürtyp.SelectedValue + "," + cbTürblattmaterial.SelectedValue + "," + cbTuerzargenmaterial.SelectedValue + "," + txtGlasflaeche.Text + "," + cbAntrieb.SelectedValue;
                        //var myWindow =
                        Window.GetWindow(this).Close();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter correct input values");
                }
            }
            else
            {
                string updatedcolumns = "türtyp='" + cbTürtyp.SelectedValue + "' , breite='" + txtBreite.Text + "' , hoehe='" + txtHohe.Text + "' , türblattmaterial='" + cbTürblattmaterial.SelectedValue + "' , [glasflaeche einseitig]='" + txtGlasflaeche.Text + "' , antrieb='" + cbAntrieb.SelectedValue + "'";
                msg = EquipmentData.UpdateEquipment("as_tuer", updatedcolumns, Equipment.getEquipId);
                if (msg == "Executed")
                {
                    UpdateChildGetSet     = true;
                    SelectChildTypeValues = "EquipId " + Equipment.getEquipId + ": " + "tuer" + " (" + txtHohe.Text + "x" + txtBreite.Text + ")," + cbTürtyp.SelectedValue + "," + cbTürblattmaterial.SelectedValue + "," + cbTuerzargenmaterial.SelectedValue + "," + txtGlasflaeche.Text + "," + cbAntrieb.SelectedValue;
                    Window.GetWindow(this).Close();
                }
                else
                {
                    MessageBox.Show("Please enter correct input values");
                }
            }
        }