Ramco Ramco

Ramco Ramco

  • 436
  • 3.4k
  • 545.9k

RollBack Transaction

Apr 4 2023 5:29 AM

Hi

  I have below code & i want if error comes then it should RollBack all transactions

foreach (var colum in Result)
                    {
                        DateTime? vSessionDate = null;
                        DateTime? vSessionStartTime = null;
                        DateTime? vSessionEndTime = null;

                        SessionDeliveryCalendar Rec = bALSessionDeliveryCalendar.GetRecordDetail(colum.SessionDeliveryCalendarID);

                        String vTime = Convert.ToDateTime(colum.SessionStartTime).ToString("HH") + ":" + Convert.ToDateTime(colum.SessionStartTime).ToString("mm");
                        String vDT1 = Convert.ToDateTime(Rec.SessionDate).AddDays(7 * Convert.ToInt32(ddlPush.SelectedValue)).ToString("dd-MM-yyyy") + " " + vTime;
                        DateTime StartDate = DateTime.ParseExact(vDT1, "dd-MM-yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                        vSessionStartTime = Convert.ToDateTime(StartDate.ToString("yyyy-MM-dd HH:mm"));


                        int Res = bALSessionDeliveryCalendar.UpdateSessionDeliveryCalendar(Rec);
                        if (Res != 0)
                        {
                            vStatus = "T";
                        }
                        else
                        {
                            vStatus = "F";
                            ShowMessage("Error", "Record Update Failed, Please Try Again", "error");
                            BindData(Convert.ToInt32(hdfGroupID.Value), Convert.ToInt32(hdfModuleID.Value), true);
                            GetGroupInfo();
                        }
                    }

Thanks


Answers (4)