Esempio n. 1
0
 public ActionResult Remove(string data)
 {
     if (asset.View)
     {
         using (var dbConn = Helpers.OrmliteConnection.openConn())
             using (var dbTrans = dbConn.OpenTransaction(IsolationLevel.ReadCommitted))
             {
                 try
                 {
                     string[] separators = { "@@" };
                     var      listRowID  = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                     foreach (var item in listRowID)
                     {
                         DC_TeleSale_AnnouncementByCS check = new DC_TeleSale_AnnouncementByCS();
                         check.Id = int.Parse(item);
                         dbConn.Delete(check);
                     }
                     dbTrans.Commit();
                 }
                 catch (Exception e)
                 {
                     log.Error(e);
                     return(Json(new { success = false, message = e }));
                 }
                 return(Json(new { success = true }));
             }
     }
     else
     {
         return(Json(new { success = false, message = "You don't have permission to delete record" }));
     }
 }
Esempio n. 2
0
        public ActionResult SaveAnnouncementTeleSale(string Message, string Impact)
        {
            if (asset.View)
            {
                if (string.IsNullOrEmpty(Message) || string.IsNullOrEmpty(Impact))
                {
                    return(Json(new { success = false, error = "Please input data" }));
                }
                else
                {
                    using (var dbConn = Helpers.OrmliteConnection.openConn())
                        using (var dbTrans = dbConn.OpenTransaction(IsolationLevel.ReadCommitted))
                        {
                            try
                            {
                                var data = new DC_TeleSale_AnnouncementByCS();

                                data.Impact             = Impact;
                                data.Message            = Message;
                                data.RowCreatedTime     = DateTime.Now;
                                data.RowCreatedUser     = currentUser.UserName;
                                data.RowLastUpdatedTime = DateTime.Parse("1900-01-01");
                                data.RowLastUpdatedUser = "";
                                data.Status             = true;

                                dbConn.Insert(data);
                                dbTrans.Commit();
                                return(Json(new { success = true }));
                            }
                            catch (Exception e)
                            {
                                dbTrans.Rollback();
                                return(Json(new { success = false, error = e.Message }));
                            }
                        }
                }
            }
            else
            {
                return(Json(new { success = false, error = "You don't have permission to create record " }));
            }
        }