示例#1
0
 private void BtnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtDescription.Text != string.Empty && txtName.Text != string.Empty)
         {
             string         strQuery        = $"update Categorias set Nombre='{txtName.Text}',Descripcion = '{txtDescription.Text}' where id_categoria ={dgvCategorys.Rows[dgvCategorys.CurrentRow.Index].Cells[0].Value.ToString()} ";
             frmInformation frmUpdateResult = new frmInformation("¿Actualizar categoria?");
             DialogResult   result          = new DialogResult();
             result = frmUpdateResult.ShowDialog();
             if (result == DialogResult.OK)
             {
                 DB.ExecuteQuery(strQuery);
                 frmRealizado frmCheced = new frmRealizado("Registro actualizado con exito");
                 result = frmCheced.ShowDialog();
                 if (result == DialogResult.OK)
                 {
                     frmCheced.Close();
                     dgvCategorys.DataSource = getInfoCategory();
                     dgvCategorys.Columns["id_categoria"].Visible = false;
                     txtDescription.Text = "";
                     txtName.Text        = "";
                 }
             }
         }
         else
         {
             MessageBox.Show("Rellene los Campos", "Campos Vacios", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 private void UpdateProduct()
 {
     if (txtName.Text != string.Empty && textBox1.Text != string.Empty && txtPriceSale.Text != string.Empty && txtDescription.Text != string.Empty)
     {
         string         strQuery  = $@"update Producto set Nombre='{txtName.Text}',Descripcion='{txtDescription.Text}',Precio_Unitario={textBox1.Text.Replace(",",".")},Precio_Compra={txtPriceSale.Text.Replace(",", ".")},
                         Categoria={CmCategory.SelectedValue.ToString()} where id_producto={dgvProducts.Rows[dgvProducts.CurrentRow.Index].Cells[0].Value.ToString()}";
         frmInformation frmUpdate = new frmInformation("Actualzar Producto");
         DialogResult   result    = new DialogResult();
         result = frmUpdate.ShowDialog();
         if (result == DialogResult.OK)
         {
             DB.ExecuteQuery(strQuery);
             frmRealizado frmCheked = new frmRealizado("Producto Actualizado");
             result = frmCheked.ShowDialog();
             if (result == DialogResult.OK)
             {
                 txtDescription.Text = "";
                 txtName.Text        = "";
                 txtPriceSale.Text   = "";
                 textBox1.Text       = "";
                 UpdateTable();
             }
         }
     }
     else
     {
         MessageBox.Show("Rellene los Campos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void DeleteProduct()
 {
     try
     {
         if (txtName.Text != string.Empty && textBox1.Text != string.Empty && txtPriceSale.Text != string.Empty && txtDescription.Text != string.Empty)
         {
             string         strQuery  = $"Delete from Producto where id_producto={dgvProducts.Rows[dgvProducts.CurrentRow.Index].Cells[0].Value.ToString()}";
             frmInformation frmDelete = new frmInformation("¿Eliminar Producto?");
             DialogResult   result    = new DialogResult();
             result = frmDelete.ShowDialog();
             if (result == DialogResult.OK)
             {
                 DB.ExecuteQuery(strQuery);
                 UpdateTable();
                 frmRealizado frmchecked = new frmRealizado("Producto Eliminado");
                 result = frmchecked.ShowDialog();
                 if (result == DialogResult.OK)
                 {
                     txtDescription.Text = "";
                     txtName.Text        = "";
                     txtPriceSale.Text   = "";
                     textBox1.Text       = "";
                 }
             }
         }
         else
         {
             MessageBox.Show("Rellene los Campos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            clsParameter._isLoadHoSoDauThau = true;
            Int64 _tongDiemKT = 0;

            for (int i = 0; i < dtDiemKyThuat.Columns.Count; i++)
            {
                string _NHOM_KYTHUAT_CT_ID = dtDiemKyThuat.Columns[i].ColumnName;
                if (_NHOM_KYTHUAT_CT_ID != "TONG_DIEM_KT")
                {
                    _tongDiemKT += Convert.ToInt64(dtDiemKyThuat.Rows[0][i]);
                    string str = string.Format("update DAUTHAU_CT set DIEM={0} where DAUTHAU_ID = {1} and NHOM_KYTHUAT_CT_ID = {2}"
                                               , dtDiemKyThuat.Rows[0][i]
                                               , _dauThauID
                                               , _NHOM_KYTHUAT_CT_ID);
                    SqlCommand cmd = new SqlCommand(str, clsConnection._conn);
                    cmd.ExecuteNonQuery();

                    //Cap nhat tong diem
                    str = string.Format("update DAU_THAU set TONG_DIEM_KT = {0} where DAUTHAU_ID = {1}", _tongDiemKT, _dauThauID);
                    cmd = new SqlCommand(str, clsConnection._conn);
                    cmd.ExecuteNonQuery();
                }
            }
            frmInformation f = new frmInformation("Lưu dữ liệu thành công.");

            f.ShowDialog();
        }
示例#5
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     try
     {
         frmInformation Info   = new frmInformation("Salir");
         DialogResult   Result = new DialogResult();
         Result = Info.ShowDialog();
         if (Result == DialogResult.OK)
         {
             this.Close();
         }
         else
         {
             Info.Close();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#6
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtDescription.Text != string.Empty && txtName.Text != string.Empty)
         {
             string         strQuery  = $"Delete from Categorias where Nombre ='{txtName.Text}' and Descripcion = '{txtDescription.Text}'";
             DialogResult   result    = new DialogResult();
             frmInformation frmDelete = new frmInformation("¿Eliminar Categoria?");
             result = frmDelete.ShowDialog();
             if (result == DialogResult.OK)
             {
                 frmDelete.Close();
                 DB.ExecuteQuery(strQuery);
                 frmRealizado frmChecked = new frmRealizado("Categoria Eliminada");
                 result = frmChecked.ShowDialog();
                 if (result == DialogResult.OK)
                 {
                     frmChecked.Close();
                     dgvCategorys.DataSource = getInfoCategory();
                     dgvCategorys.Columns.Remove("id_categoria");
                     txtDescription.Text = "";
                     txtName.Text        = "";
                 }
             }
         }
         else
         {
             MessageBox.Show("Rellene los campos", "Campos Vacios", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }