Beispiel #1
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     MaterialAddEditForm maef = new MaterialAddEditForm(
         "Добавить материал");
     if (maef.ShowDialog() == DialogResult.OK)
     {
         data.Tables["material"].Rows.Add(maef.Result);
         postgreConnection.UpdateDB("material", data, 1);
     }
 }
Beispiel #2
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         MaterialAddEditForm maef = new MaterialAddEditForm(
             "Редактировать материал",
             isEditable: true,
             data: data.Tables["material"].Select("id=" + dataGridView1.SelectedRows[0].Cells["id"].Value.ToString())[0].ItemArray,
             buttonCaption: "Редактировать");
         if (maef.ShowDialog() == DialogResult.OK)
         {
             data.Tables["material"].Select("id=" + dataGridView1.SelectedRows[0].Cells["id"].Value.ToString())[0].ItemArray = maef.Result;
             postgreConnection.UpdateDB("material", data, 2);
         }
     }
 }
Beispiel #3
0
        private void additionalInfoButton_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                currAction = 0;
                bool flag = false;
                tabControl1.SelectedIndex = 0;
                MaterialAddEditForm maef = new MaterialAddEditForm(
                        "Добавить материал");
                if (maef.ShowDialog() == DialogResult.OK)
                {
                    MaterialCountAddEditForm mcaef = new MaterialCountAddEditForm(
                            "Количество материалов",
                            "Добавить");
                    if (mcaef.ShowDialog() == DialogResult.OK)
                    {
                        dataSet1.Tables["material"].Rows.Add(maef.Result);
                        if (postgreConnection.UpdateDB("material", dataSet1, 1))
                        {
                            flag = true;
                            dataSet1.Tables["use_material"].Rows.Add(new object[]{
                        null,
                        listBox1.SelectedValue,
                        dataSet1.Tables["material"].Rows[dataSet1.Tables["material"].Rows.Count-1].ItemArray[0],
                        mcaef.Result[0]
                    });
                            if (postgreConnection.UpdateDB("use_material", dataSet1, 1))
                                flag = true;
                        }
                    }

                }
                if (flag)
                    DrawData();
            }
        }
Beispiel #4
0
 private void menuItemWithAccessLevel18_Click(object sender, EventArgs e)
 {
     MaterialAddEditForm maef = new MaterialAddEditForm("Добавить материал");
     if (maef.ShowDialog() == DialogResult.OK)
     {
         globalDS.Tables["material"].Rows.Add(maef.Result);
         postgreConnection.UpdateDB("material", globalDS, 1);
     }
 }
Beispiel #5
0
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     bool flag = false;
     if(addMaterialDataGridView.SelectedRows.Count>0)
     {
         int mat_id = (int)addMaterialDataGridView.SelectedRows[0].Cells["id"].Value;
         MaterialAddEditForm maef = new MaterialAddEditForm(
             "Изменить материал",
             data: dataSet1.Tables["material"].Select("id=" + mat_id.ToString())[0].ItemArray,
             buttonCaption: "Редактировать");
         if(maef.ShowDialog() == DialogResult.OK)
         {
             dataSet1.Tables["material"].Select("id=" + mat_id.ToString())[0].ItemArray = maef.Result;
             if (postgreConnection.UpdateDB("material", dataSet1, 2))
                 flag = true;
             if ((bool)addMaterialDataGridView.SelectedRows[0].Cells[0].Value == true)
             {
                 MaterialCountAddEditForm mcaef = new MaterialCountAddEditForm(
                 "Количество материалов",
                 "Изменить",
                 data: addMaterialDataGridView.SelectedRows[0].Cells["count"].Value);
                 if (mcaef.ShowDialog() == DialogResult.OK)
                 {
                     object[] arr = dataSet1.Tables["use_material"].Select(String.Format(
                    "work_id={0} and material_id={1}",
                    ((int)listBox1.SelectedValue),
                    mat_id
                    ))[0].ItemArray;
                     arr[3] = mcaef.Result[0];
                     dataSet1.Tables["use_material"].Select(String.Format(
                    "work_id={0} and material_id={1}",
                    ((int)listBox1.SelectedValue),
                    mat_id
                    ))[0].ItemArray = arr;
                     if (postgreConnection.UpdateDB("use_material", dataSet1, 2))
                         flag = true;
                 }
             }
             if (flag)
                 DrawData();
         }
     }
 }