示例#1
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();
            }
        }
示例#2
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();
         }
     }
 }
示例#3
0
 private void addMaterialDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     int mat_count = 1;
     if (e.RowIndex != -1)
     {
         if (!(bool)addMaterialDataGridView.Rows[e.RowIndex].Cells[0].Value)
         {
             dataSet1.Tables["use_material"].Select(String.Format(
                 "work_id={0} and material_id={1}",
                 ((int)listBox1.SelectedValue),
                 addMaterialDataGridView.Rows[e.RowIndex].Cells["id"].Value
                 ))[0].Delete();
             if(postgreConnection.UpdateDB("use_material", dataSet1, 3))
                 DrawData();
         }
         else
         {
             MaterialCountAddEditForm maef = new MaterialCountAddEditForm(
             "Количество материала",
              "Создать");
             if (maef.ShowDialog() == DialogResult.OK)
             {
                 mat_count = int.Parse(maef.Result[0].ToString());
             }
             dataSet1.Tables["use_material"].Rows.Add(new object[] {
                 null,
                 (int)listBox1.SelectedValue,
                 addMaterialDataGridView.Rows[e.RowIndex].Cells["id"].Value,
                 mat_count});
             if (postgreConnection.UpdateDB("use_material", dataSet1, 1))
                 DrawData();
         }
     }
 }