protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.Form["OrderID"])) { int OrderID = Int32.Parse(Request.Form["OrderID"].ToString()); OrderDAL dal = new OrderDAL(strConnSitring); CommissionDAL dal_commission = new DeltoneCRM_DAL.CommissionDAL(strConnSitring); String pre_status = dal.getCurrentOrderStatus(OrderID); orderdal = new OrderDAL(strConnSitring); String output = orderdal.CancelOrder(OrderID); if (Int32.Parse(output) > 0) { xero = new XeroIntergration(); Repository repos = xero.CreateRepository(); String strOrderGuid = orderdal.getOrderGuid(OrderID); XeroApi.Model.Invoice cancelInvoice = xero.CancelInvoice(OrderID, repos, pre_status, strOrderGuid); if (cancelInvoice != null) { } } output = dal_commission.RemoveCommissionEntry(OrderID, "ORDER"); var orderDtsNumber = orderdal.getXeroDTSID(OrderID); UpdateInHouseCancelRecord(OrderID, orderDtsNumber); Response.Write(orderdal.CancelOrder(OrderID)); } }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.Form["creditnoteid"])) { int OrderID = Int32.Parse(Request.Form["creditnoteid"].ToString()); CreditNotesDAL creditdal = new CreditNotesDAL(strConnSitring); CommissionDAL dal_Commision = new DeltoneCRM_DAL.CommissionDAL(strConnSitring); String pre_status = creditdal.getCurrentCreditNoteStatus(OrderID); //Fetch the PRevious Status String strCreditNoteGuid = creditdal.getCreditNote_XeroGuid(OrderID); //Fetch the credit note Xero Guid String Result = String.Empty; if (!String.IsNullOrEmpty(strCreditNoteGuid)) { xero = new XeroIntergration(); Repository repos = xero.CreateRepository(); XeroApi.Model.CreditNote cancelCreditNote = xero.CancelCreditNote(OrderID, repos, pre_status, strCreditNoteGuid); String connectionstring = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; //CANCEL THE CREDIT NOTE IN DELTONE SYSTEM Result = (cancelCreditNote != null) ? "SUCCESS" : "ERROR"; var previousValues = pre_status; if (Result.Equals("SUCCESS")) { var columnName = "Status"; var talbeName = "CreditNote"; var ActionType = "CANCELLED"; int primaryKey = OrderID; var orderIdForCreditNote = new CreditNotesDAL(connectionstring).getOrderIDFromCreditID(OrderID); var newvalues = " CreditNote Id " + OrderID + " :Credit Ortder Status changed from " + previousValues + " to CANCELLED"; var loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString()); SqlConnection conn = new SqlConnection(); conn.ConnectionString = connectionstring; var strCompanyID = new CreditNotesDAL(connectionstring).getCompanyIDFromCreditID(OrderID); new DeltoneCRM_DAL.CompanyDAL(connectionstring).CreateActionONAuditLog(previousValues, newvalues, loggedInUserId, conn, 0, columnName, talbeName, ActionType, primaryKey, Convert.ToInt32(strCompanyID)); creditdal.CancelCreditNote(OrderID); dal_Commision.RemoveCommissionEntry(OrderID, "CREDITNOTE"); } } else { Result = "ERROR"; } Response.Write(Result); } }