示例#1
0
    private void Delete()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Delete))
        {
            return;
        }

        if (ValidateValues() == false)
        {
            return;
        }
        bool bActionCompleted = false;
        int  Id = 0;

        int.TryParse(hfId.Value, out Id);
        if (Id == 0)
        {
            lblStatus.Text = "Please click on edit button again.";
            return;
        }
        MealPlanMaster oMealPlanMaster = new MealPlanMaster();
        MealPlanDTO    oMealPlanData   = new MealPlanDTO();

        oMealPlanData.MealPlanId = Id;

        /*
         * ADDED BY VIJAY
         * CHECK IF THE FLOOR WHICH IS TO BE DELETED HAS ANY ASSOCIATED RECORDS...IF YES, MOVE OUT OF THE FUNCTION ELSE PROCEED
         * IF THE OUTPUT OF sMessage IS "", THEN RECORD CAN BE DELETED, ELSE NOT
         *
         */
        string sMessage = "";

        GF.HasRecords(Convert.ToString(Id), "mealplan", out sMessage);
        if (sMessage != "")
        {
            base.DisplayAlert(sMessage);
            btnDelete.Enabled = true;
        }
        else
        {
            bActionCompleted = oMealPlanMaster.Delete(oMealPlanData);
            if (bActionCompleted == true)
            {
                base.DisplayAlert("The record has been deleted successfully");
                ClearControls();
                RefreshGrid();
                //lblStatus.Text = "Deleted";
            }
            else
            {
                base.DisplayAlert("Error Occured while deletion: Please refer to the error log.");
            }
        }
        oMealPlanData   = null;
        oMealPlanMaster = null;
    }
示例#2
0
    protected void dgMealPlans_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        int            iMealPlanID     = Convert.ToInt32(dgMealPlans.DataKeys[e.Item.ItemIndex].ToString());
        MealPlanMaster oMealPlanMaster = new MealPlanMaster();
        MealPlanDTO    oMealPlanData   = new MealPlanDTO();

        oMealPlanData.MealPlanId = iMealPlanID;
        oMealPlanMaster.Delete(oMealPlanData);
        txtMealPlanName.Text = "";
        txtMealPlanCode.Text = "";
        txtMealPlanDesc.Text = "";
        RefreshGrid();
        oMealPlanData   = null;
        oMealPlanMaster = null;
    }