コード例 #1
0
        private void btnReturn_Click(object sender, EventArgs e)
        {
            int MiniUnitOrder = Convert.ToInt32(dgvMiniUnit.CurrentRow.Cells[0].Value);
            int MaxMU         = Convert.ToInt32(dgvMiniUnit.CurrentRow.Cells[1].Value);
            int UpdateMaxMU   = MaxMU + Convert.ToInt16(nudMaxSplitMU.Value);
            int count         = 0;

            // 1 - Insert the updated value
            if (gboMain.Text == "Bulk")
            {
                dbCeres.getDataByQuery("update miniunit set TotalBilled = " + UpdateMaxMU.ToString() + " where UnitSourceId = " + UnitSourceId.ToString() + " and MiniUnitOrder = " + MiniUnitOrder.ToString());
            }
            else
            {
                dbCeres.getDataByQuery("update miniunit set PCBilled = " + UpdateMaxMU.ToString() + " where UnitSourceId = " + UnitSourceId.ToString() + " and MiniUnitOrder = " + MiniUnitOrder.ToString());
            }

            // 2 - Deletes the MiniUnit row
            dbCeres.deleteMiniUnit("delete from MiniUnit where MiniUnitId = " + MiniUnitId.ToString());

            // 3 - Updates the order of Mini Units
            foreach (DataRow mini in dbCeres.getTableInfo("MiniUnit", "*", "where UnitSourceId = " + UnitSourceId.ToString() + " order by MiniUnitId").Rows)
            {
                count += 1;
                dbCeres.getDataByQuery("update miniunit set MiniUnitOrder = " + count.ToString() + " where MiniUnitId = " + mini["MiniUnitId"].ToString());
            }

            MessageBox.Show("Return made successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            My.MyProject.Forms.FrmEditAddRailList.PopulateMU();
            Close();
        }