public ActionResult HandleChanges(StoreDataHandler handler)
        {
            ChangeRecords <TestPerson> persons = handler.BatchObjectData <TestPerson>();
            var store = this.GetCmp <Store>("Store1");

            foreach (TestPerson created in persons.Created)
            {
                TestPerson.AddPerson(created);

                var record = store.GetByInternalId(created.PhantomId);
                record.CreateVariable = true;
                record.SetId(created.Id);
                record.Commit();
                created.PhantomId = null;
            }

            foreach (TestPerson deleted in persons.Deleted)
            {
                TestPerson.DeletePerson(deleted.Id.Value);
                store.CommitRemoving(deleted.Id.Value);
            }

            foreach (TestPerson updated in persons.Updated)
            {
                TestPerson.UpdatePerson(updated);

                var record = store.GetById(updated.Id.Value);
                record.Commit();
            }

            return(this.Direct());
        }
Beispiel #2
0
        public AjaxStoreResult SaveCustomersWithConfirmation()
        {
            AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);

            try
            {
                NorthwindDataContext     db               = this.DBContext;
                StoreDataHandler         dataHandler      = new StoreDataHandler(HttpContext.Request["data"]);
                ChangeRecords <Customer> data             = dataHandler.ObjectData <Customer>();
                ConfirmationList         confirmationList = dataHandler.BuildConfirmationList("CustomerID");

                foreach (Customer customer in data.Deleted)
                {
                    db.Customers.Attach(customer);
                    db.Customers.DeleteOnSubmit(customer);
                }

                foreach (Customer customer in data.Updated)
                {
                    db.Customers.Attach(customer);
                    db.Refresh(RefreshMode.KeepCurrentValues, customer);
                }

                foreach (Customer customer in data.Created)
                {
                    //customer.TemporaryID = customer.CustomerID;
                    db.Customers.InsertOnSubmit(customer);
                }

                db.SubmitChanges();

                //ideally we should confirm after each operation
                //but LINQ make batch submit of changes

                foreach (Customer customer in data.Deleted)
                {
                    confirmationList[customer.CustomerID].ConfirmRecord();
                }

                foreach (Customer customer in data.Updated)
                {
                    confirmationList[customer.CustomerID].ConfirmRecord();
                }

                foreach (Customer customer in data.Created)
                {
                    confirmationList[customer.CustomerID].ConfirmRecord();
                }


                ajaxStoreResult.SaveResponse.ConfirmationList = confirmationList;
            }
            catch (Exception e)
            {
                ajaxStoreResult.SaveResponse.Success      = false;
                ajaxStoreResult.SaveResponse.ErrorMessage = e.Message;
            }

            return(ajaxStoreResult);
        }
Beispiel #3
0
    protected void grpBangThanhToanTienLuongStoreChange(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <BangThanhToanTienLuongInfo> bangthanhtoan = e.DataHandler.ObjectData <BangThanhToanTienLuongInfo>();

        foreach (var item in bangthanhtoan.Updated)
        {
            var change = new BangThanhToanTienLuongController().GetChiTietLuongByID(item.ID);
            change.LuongCoBan              = item.LuongCoBan;
            change.LuongTrachNhiem         = item.LuongTrachNhiem;
            change.PhuCapTienAn            = item.PhuCapTienAn;
            change.PhuCapChucVu            = item.PhuCapChucVu;
            change.PhuCapKiemNhiem         = item.PhuCapKiemNhiem;
            change.PhuCapKhac              = item.PhuCapKhac;
            change.LuongThoiGianNgayThuong = item.LuongThoiGianNgayThuong;
            change.LuongThemGio            = item.LuongThemGio;
            change.LuongThuong             = item.LuongThuong;
            change.LuongThang13            = item.LuongThang13;
            change.ATM     = item.ATM;
            change.TienMat = item.TienMat;

            new BangThanhToanTienLuongController().UpdateChiTietTienLuong(change);
            grpBangThanhToanTienLuongStore.CommitChanges();
            grpBangThanhToanTienLuong.Reload();
        }
    }
    //protected void btnSave_Click(object sender, DirectEventArgs e)
    //{
    //    List<string> lists = new List<string>();
    //    string[] nhanxet = hdfNhanXet.Text.Split('#');
    //    for (int i = nhanxet.Count() - 1; i >= 0; i--)
    //    {
    //        if (nhanxet[i].Trim() != "")
    //        {
    //            string[] tmp = nhanxet[i].Split('$');
    //            if (!lists.Contains(tmp[0].Trim()))
    //            {
    //                new KetQuaDanhGiaController().UpdateNhanXetByID(int.Parse("0" + tmp[0]), tmp[1]);
    //                lists.Add(tmp[0].Trim());
    //            }
    //        }
    //    }
    //    hdfNhanXet.Text = "";
    //    grp_TieuChiDanhGia.Reload();
    //    grp_CanBoBiDanhGia.Reload();
    //}

    protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <TienHanhDanhGia> canbos = e.DataHandler.ObjectData <TienHanhDanhGia>();

        foreach (TienHanhDanhGia updated in canbos.Updated)
        {
            DAL.TieuChi_DotDanhGia tc   = new TieuChi_DotDanhGiaController().GetByMaDotDanhGiavaMaTieuChi(hdfMaDotDanhGia.Text, updated.MaNhom);
            KetQuaDanhGiaInfo      kqua = new KetQuaDanhGiaInfo()
            {
                ID                   = updated.ID,
                CreatedBy            = CurrentUser.ID,
                CreatedDate          = DateTime.Now,
                Diem                 = (float)Math.Round(updated.Diem, 2),
                IdTieuChi_DotDanhGia = tc.ID,
                MaCB                 = hdfMaCanBo.Text,
                NhanXet              = updated.NhanXet
            };
            if (isNguoiQL == true)
            {
                kqua.IsQuanLyDanhGia = true;
            }
            // update kết quả
            new KetQuaDanhGiaController().Update(kqua);
        }
        e.Cancel = true;
        Dialog.ShowNotification("Đã lưu kết quả đánh giá");
        // cập nhật kết quả hàng tháng
        try
        {
            DataController.DataHandler.GetInstance().ExecuteNonQuery("DanhGia_UpdateDanhGiaTheoThang", "@MaCanBo", "@MaDotDanhGia", hdfMaCanBo.Text, hdfMaDotDanhGia.Text);
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #5
0
    protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <BangChamCongThangInfo> bangchamcongthang = e.DataHandler.ObjectData <BangChamCongThangInfo>();

        foreach (BangChamCongThangInfo update in bangchamcongthang.Updated)
        {
        }
    }
Beispiel #6
0
    protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <KEHOACH_DAOTAOInfo> records = e.DataHandler.ObjectData <KEHOACH_DAOTAOInfo>();

        foreach (KEHOACH_DAOTAOInfo item in records.Deleted)
        {
            new DaoTaoController().Delete(item.MaKeHoach);
        }
    }
Beispiel #7
0
    protected void HandleChangesGiaoVien(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <GiaoVienThamGiaDaoTaoInfo> records = e.DataHandler.ObjectData <GiaoVienThamGiaDaoTaoInfo>();
        DaoTaoController controller = new DaoTaoController();

        foreach (GiaoVienThamGiaDaoTaoInfo item in records.Deleted)
        {
            controller.DeleteGiaoVien(item.MaGV, hdfRecordID.Text);
        }
    }
Beispiel #8
0
    protected void HandleChangesChiPhi(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <CacKhoanChiPhiInfo> records = e.DataHandler.ObjectData <CacKhoanChiPhiInfo>();
        DaoTaoController controller = new DaoTaoController();

        foreach (CacKhoanChiPhiInfo item in records.Deleted)
        {
            controller.DeleteChiPhi(item.ID);
        }
    }
        private int GetLatestCodeChange()
        {
            List <P4Connection.ChangeRecord> ChangeRecords;

            if (!P4.Changes(out ChangeRecords, String.Format("-m 1 //{0}/....cpp@<{1} //{0}/....h@<{1} //{0}/....cs@<{1} //{0}/....usf@<{1} //{0}/....ush@<{1}", P4Env.Client, P4Env.Changelist), WithClient: true))
            {
                throw new AutomationException("Couldn't enumerate latest change from branch");
            }
            return(ChangeRecords.Max(x => x.CL));
        }
Beispiel #10
0
    public void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        try
        {
            string error = string.Empty;
            ChangeRecords <BangTamUngInfo> tamUngs = e.DataHandler.ObjectData <BangTamUngInfo>();

            foreach (BangTamUngInfo created in tamUngs.Created)
            {
                try
                {
                    // create BangTamUng object
                    BangTamUng tamUng = new BangTamUng();
                    tamUng.PrKeyHoSo   = created.PrkeyHoSo;
                    tamUng.SoTien      = created.SoTien;
                    tamUng.SoTienDaTra = created.SoTienDaTra;
                    tamUng.LyDoTamUng  = created.LyDoTamUng;
                    if (created.NgayTamUng != null)
                    {
                        tamUng.NgayTamUng = created.NgayTamUng.Value;
                    }
                    if (created.NgayThanhToan != null)
                    {
                        tamUng.ThoiHanThanhToan = created.NgayThanhToan.Value;
                    }
                    tamUng.CreatedBy     = CurrentUser.ID;
                    tamUng.CreatedDate   = DateTime.Now;
                    tamUng.NgayThanhToan = null;

                    // insert data to database
                    new BangTamUngController().Insert(tamUng);
                }
                catch (Exception ex)
                {
                    error += ex.Message + "\n";
                }
            }
            // show error if valid
            if (!string.IsNullOrEmpty(error))
            {
                X.Msg.Alert("Có lỗi xảy ra", error).Show();
            }
            else
            {
                Dialog.ShowNotification("Thêm cán bộ tạm ứng thành công!");
                wdCapNhatTamUngHangLoat.Hide();
            }
            grpBangTamUng.GetGridPanel().Reload();
        }
        catch (Exception ex)
        {
            X.Msg.Alert("Thông báo", "Có lỗi xảy ra: " + ex.Message).Show();
        }
    }
        protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
        {
            ChangeRecords <Sjqd_Lan> list = e.DataHandler.ObjectData <Sjqd_Lan>();

            foreach (Sjqd_Lan updated in list.Updated)
            {
                Sjqd_CpuService.UpdateLan(updated);
                if (Store3.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(updated.ID.ToString());
                }
            }
            X.Msg.Alert("消息", "保存成功").Show();
            e.Cancel = true;
        }
        protected virtual void btnDelete_Click(object sender, DirectEventArgs e)
        {
            string error = string.Empty;

            try
            {
                ChangeRecords <TModel> changes = GetChangedRecords(e);
                Presenter.SaveModel(null, null, changes.Deleted);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            ResMgr.AddScript(error == string.Empty ? "DeleteSuccess();" : "DeleteFailure();");
        }
Beispiel #13
0
    protected void HandleChangesDaoTao(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <NhanVienThamGiaDaoTaoInfo> record = e.DataHandler.ObjectData <NhanVienThamGiaDaoTaoInfo>();
        DaoTaoController controller = new DaoTaoController();

        foreach (var item in record.Deleted)
        {
            controller.DeleteNhanVien(item.ID);
        }

        foreach (NhanVienThamGiaDaoTaoInfo item in record.Updated)
        {
            controller.UpdateNhanVien(item);
        }
    }
Beispiel #14
0
    protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        try
        {
            ChangeRecords <DangKyLamThemGioHangLoatInfo> dky = e.DataHandler.ObjectData <DangKyLamThemGioHangLoatInfo>();
            string error = string.Empty;

            foreach (DangKyLamThemGioHangLoatInfo created in dky.Created)
            {
                DAL.DangKyLamThemGio lamtg = new DangKyLamThemGio
                {
                    MaCB            = created.MA_CB,
                    FrkeyMaCa       = int.Parse(cbxChonCaHL.SelectedItem.Value),
                    TuNgay          = dfTuNgayHL.SelectedDate,
                    DenNgay         = dfDenNgayHL.SelectedDate,
                    GioBatDauSauCa  = GetTime(tfGioBatDauHL.Text),
                    GioKetThucSauCa = GetTime(tfGioKetThucHL.Text),
                    CreatedBy       = CurrentUser.ID,
                    CreatedDate     = DateTime.Now,
                    GhiChu          = txtGhiChuHL.Text,
                };
                List <DAL.DangKyLamThemGio> tmp = new DangKyLamThemGioController().GetByMaCanBoAndFrkeyCa(lamtg.MaCB, lamtg.FrkeyMaCa);
                if (CheckGiaoNhau(tmp, lamtg) == false)
                {
                    new DangKyLamThemGioController().Insert(lamtg);
                }
                else
                {
                    error += lamtg.MaCB + ", ";
                }
            }
            grpDangKyLamThemGio.Reload();
            if (string.IsNullOrEmpty(error))
            {
                Dialog.ShowNotification("Đăng ký thành công!");
            }
            else
            {
                error = error.Remove(error.LastIndexOf(','));
                X.Msg.Alert("Thông báo từ hệ thống", "Các cán bộ có mã " + error + " đã đăng ký trùng giờ làm thêm").Show();
            }
            wdThemCanBoHangLoat.Hide();
        }
        catch (Exception ex)
        {
            X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show();
        }
    }
Beispiel #15
0
        protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
        {
            ChangeRecords <SimpleProjectource> list = e.DataHandler.ObjectData <SimpleProjectource>();

            foreach (SimpleProjectource updated1 in list.Updated)
            {
                var updated = ConvertToProject(updated1);
                biService.UpdateProjectSource(updated);
                if (Store4.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(updated.ProjectSourceID.ToString());
                }
            }
            X.Msg.Alert("消息", "保存修改成功").Show();
            e.Cancel = true;
        }
    protected void HandleChangesTuDien(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <MathRule> mathRule = e.DataHandler.ObjectData <MathRule>();
        XMLProcess xmlProcess             = new XMLProcess();

        foreach (var item in mathRule.Updated)
        {
            xmlProcess.UpdateTuDien(Server.MapPath(MathRuleXmlUrl), item);
            GridPanel2.UpdateCell(item.ColumnInDB, "MathStatus", "true");
            if (Store3.UseIdConfirmation)
            {
                e.ConfirmationList.ConfirmRecord(item.ColumnInDB.ToString());
            }
            hdfMathStatus.Text = hdfMathStatus.Text.Replace(item.ColumnInDB + ",", "");
        }
    }
        protected virtual void btnSave_Click(object sender, DirectEventArgs e)
        {
            string error = string.Empty;

            try
            {
                ChangeRecords <TModel> changes = GetChangedRecords(e);
                Presenter.SaveModel(changes.Created, changes.Updated, changes.Deleted);
            }
            catch (Exception ex) //change to crud ex
            {
                error = ex.Message;
            }

            ResMgr.AddScript(error == string.Empty ? "SaveSuccess();" : string.Format("SaveFailure('{0}');", error));
        }
Beispiel #18
0
        public ActionResult SaveCode(int taskId)
        {
            AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);

            try
            {
                StoreDataHandler     dataHandler = new StoreDataHandler(HttpContext.Request["data"]);
                ChangeRecords <Code> obj         = dataHandler.ObjectData <Code>();

                Task task = taskRepository.Get(taskId);
                foreach (Code code in obj.Updated)
                {
                    code.Task = task;
                    if (code.IsValid())
                    {
                        codeRepository.SaveOrUpdate(code);
                    }
                }

                foreach (Code code in obj.Created)
                {
                    code.Task = task;
                    if (code.IsValid())
                    {
                        codeRepository.SaveOrUpdate(code);
                    }
                }

                foreach (Code code in obj.Deleted)
                {
                    code.Task = task;
                    if (code.IsValid())
                    {
                        codeRepository.Delete(code);
                    }
                }
                codeRepository.DbContext.CommitChanges();
                ajaxStoreResult.SaveResponse.Success = true;
            }
            catch (Exception e)
            {
                ajaxStoreResult.SaveResponse.Success      = false;
                ajaxStoreResult.SaveResponse.ErrorMessage = e.Message;
                codeRepository.DbContext.RollbackTransaction();
            }
            return(ajaxStoreResult);
        }
Beispiel #19
0
        public ActionResult ChucvuList_Save()
        {
            AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);

            try
            {
                QLVBEntities             db               = this.DBContext;
                StoreDataHandler         dataHandler      = new StoreDataHandler(HttpContext.Request["data"]);
                ChangeRecords <DMCHUCVU> data             = dataHandler.ObjectData <DMCHUCVU>();
                ConfirmationList         confirmationList = dataHandler.BuildConfirmationList("MACHUCVU");

                foreach (DMCHUCVU c in data.Deleted)
                {
                    db.DMCHUCVUs.Attach(c);
                    db.DMCHUCVUs.DeleteObject(c);
                }

                foreach (DMCHUCVU c in data.Created)
                {
                    db.DMCHUCVUs.AddObject(c);
                }

                foreach (DMCHUCVU c in data.Updated)
                {
                    var orgRecord = db.DMCHUCVUs.Single(p => p.MACHUCVU == c.MACHUCVU);
                    db.DMCHUCVUs.ApplyCurrentValues(c);
                }

                db.SaveChanges();
            }
            catch (Exception e)
            {
                ajaxStoreResult.SaveResponse.Success = false;
                int nCode = System.Runtime.InteropServices.Marshal.GetHRForException(e);

                if (nCode == -2146233087)
                {
                    ajaxStoreResult.SaveResponse.Message = "Trùng mã chức năng.";
                }
                else
                {
                    ajaxStoreResult.SaveResponse.Message = e.InnerException.Message;
                }
            }

            return(ajaxStoreResult);
        }
Beispiel #20
0
        /// <summary>
        /// autosave cho store chứa thông tin cột
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void HandleColumnChanges(object sender, BeforeStoreChangedEventArgs e)
        {
            ChangeRecords <GridPanelColumnInfo> columns = e.DataHandler.ObjectData <GridPanelColumnInfo>();

            foreach (GridPanelColumnInfo item in columns.Updated)
            {
                lock (lockObj)
                {
                    item.TableName = this.TableName;
                    GridController.GetInstance().UpdateColumnInformation(item);
                }

                if (StoreColumnInfo.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(item.ID.ToString());
                }
            }

            foreach (GridPanelColumnInfo item in columns.Created)
            {
                lock (lockObj)
                {
                    item.TableName = this.TableName;
                    item.GridName  = this.ID;
                    GridController.GetInstance().InsertColumnInformation(item);
                }

                if (StoreColumnInfo.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(item.ID.ToString());
                }

                //  StoreColumnInfo.
            }

            foreach (GridPanelColumnInfo item in columns.Deleted)
            {
                lock (lockObj)
                {
                    GridController.GetInstance().DeleteColumnInformation(item);
                    LoadColumnTable();
                }
            }

            e.Cancel = true;
        }
        public Coolite.Ext.Web.Response SaveGameSimpleVersionList(string data)//保存GameSimpleVersionList
        {
            Response sr = new Response(true);

            if (VerirySecurityIP(GetIP4Address()))
            {
                sr.Success = false;
                sr.Msg     = msgNoSafe;
                Log.Warn(msgNoSafe + Context.Request.UserHostAddress + "<>" + GSSServerIP + "");
                return(sr);
            }

            try
            {
                GameCoreDBDataContext db          = new GameCoreDBDataContext();
                StoreDataHandler      dataHandler = new StoreDataHandler(data);
                ChangeRecords <T_GameSimpleVersionList> dataList = dataHandler.ObjectData <T_GameSimpleVersionList>();

                foreach (T_GameSimpleVersionList GameSimpleVersionList in dataList.Deleted)
                {
                    db.T_GameSimpleVersionList.Attach(GameSimpleVersionList);
                    db.T_GameSimpleVersionList.DeleteOnSubmit(GameSimpleVersionList);
                }

                foreach (T_GameSimpleVersionList GameSimpleVersionList in dataList.Updated)
                {
                    db.T_GameSimpleVersionList.Attach(GameSimpleVersionList);
                    db.Refresh(RefreshMode.KeepCurrentValues, GameSimpleVersionList);
                }

                foreach (T_GameSimpleVersionList GameSimpleVersionList in dataList.Created)
                {
                    db.T_GameSimpleVersionList.InsertOnSubmit(GameSimpleVersionList);
                }

                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                sr.Success = false;
                sr.Msg     = ex.Message;
                Log.Warn("SaveGameSimpleVersionList", ex);
            }

            return(sr);
        }
Beispiel #22
0
    /// <summary>
    /// autosave cho store chứa thông tin cột
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void HandleColumnChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <OneManyFormInfo> columns = e.DataHandler.ObjectData <OneManyFormInfo>();

        foreach (OneManyFormInfo item in columns.Updated)
        {
            lock (lockObj)
            {
                OneManyFormController.GetInstance().Update(item);
            }
            if (StoreTableDetailInfo.UseIdConfirmation)
            {
                e.ConfirmationList.ConfirmRecord(item.ID.ToString());
            }
        }
        e.Cancel = true;
    }
Beispiel #23
0
        public DirectResult SaveData(string id, FormCollection values, string startDate, string endDate)
        {
            DirectResult response = new DirectResult();

            Ext.Net.Store            store       = X.GetCmp <Ext.Net.Store>("StoreTest");
            StoreDataHandler         dataHandler = new StoreDataHandler(values["data"]);
            ChangeRecords <TestData> data        = dataHandler.BatchObjectData <TestData>();

            for (int i = 0; i < data.Updated.Count; i++)
            {
                TestData testData = data.Updated[i];

                //we want to remove the record since it is processed so we use the delete record option
                ModelProxy record = store.GetById(testData.id);
                store.Remove(record);
                store.CommitRemoving(testData.id);
            }

            return(response);
        }
Beispiel #24
0
    protected void HandleFieldChanges(object sender, BeforeStoreChangedEventArgs e)
    {
        ChangeRecords <FormElementInfo> elements = e.DataHandler.ObjectData <FormElementInfo>();

        foreach (FormElementInfo item in elements.Updated)
        {
            lock (lockObj)
            {
                if (item.GroupID == null)
                {
                    item.GroupID = 0;
                }
                FormElementController.GetInstance().Update(item);
            }
            if (StoreFieldInfo.UseIdConfirmation)
            {
                e.ConfirmationList.ConfirmRecord(item.ID.ToString());
            }
        }
    }
Beispiel #25
0
        protected virtual void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
        {
            ChangeRecords <T> persons = e.DataHandler.ObjectData <T>();

            foreach (T created in persons.Created)
            {
                string tempId = getID(created);
                string newId  = this.AddPerson(created);

                if (Store1.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(tempId.ToString(), newId.ToString());
                }
                else
                {
                    Store1.UpdateRecordId(tempId, newId);
                }
            }

            foreach (T deleted in persons.Deleted)
            {
                string id = getID(deleted);
                this.DeletePerson(id);

                if (Store1.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(id);
                }
            }

            foreach (T updated in persons.Updated)
            {
                this.UpdatePerson(updated);

                if (Store1.UseIdConfirmation)
                {
                    e.ConfirmationList.ConfirmRecord(getID(updated));
                }
            }
            e.Cancel = true;
        }
Beispiel #26
0
        public ActionResult SoVanbanList_Save()
        {
            AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);

            try
            {
                QLVBEntities           db          = this.DBContext;
                StoreDataHandler       dataHandler = new StoreDataHandler(HttpContext.Request["data"]);
                ChangeRecords <DMSOVB> data        = dataHandler.ObjectData <DMSOVB>();

                foreach (DMSOVB c in data.Deleted)
                {
                    db.DMSOVBs.Attach(c);
                    db.DMSOVBs.DeleteObject(c);
                }

                foreach (DMSOVB c in data.Created)
                {
                    c.IDSOVB = GetNewDanhmucID();
                    db.DMSOVBs.AddObject(c);
                }

                foreach (DMSOVB c in data.Updated)
                {
                    var orgRecord = db.DMSOVBs.Single(p => p.IDSOVB == c.IDSOVB);
                    db.DMSOVBs.ApplyCurrentValues(c);
                }

                db.SaveChanges();
            }
            catch (Exception e)
            {
                ajaxStoreResult.SaveResponse.Success = false;
                int nCode = System.Runtime.InteropServices.Marshal.GetHRForException(e);

                ajaxStoreResult.SaveResponse.Message = e.InnerException.Message;
            }

            return(ajaxStoreResult);
        }
Beispiel #27
0
        protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
        {
            try
            {
                ChangeRecords <SelectCustomerAction> persons = e.DataHandler.ObjectData <SelectCustomerAction>();
                foreach (SelectCustomerAction updated in persons.Updated)
                {
                    var acl = base.ACLService.GetAllAcl(updated.CustomerActionID, this._CustomerRoleID, null).FirstOrDefault();
                    if (acl == null)
                    {
                        base.ACLService.InsertAcl(new ACL()
                        {
                            CustomerActionID = updated.CustomerActionID
                            ,
                            CustomerRoleID = this._CustomerRoleID
                            ,
                            Allow = updated.Allow
                        });
                    }
                    else
                    {
                        acl.Allow = updated.Allow;
                        base.ACLService.UpdateAcl(acl);
                    }
                    try
                    {
                        e.ConfirmationList.ConfirmRecord(updated.CustomerActionID.ToString());
                    }
                    catch
                    {
                    }
                }

                e.Cancel = true;
            }
            catch (Exception err)
            {
                base.ProcessException(err);
            }
        }
Beispiel #28
0
        public Coolite.Ext.Web.Response SaveSuppliers(string data)
        {
            Response sr = new Response(true);

            try
            {
                NorthwindDataContext     db          = new NorthwindDataContext();
                StoreDataHandler         dataHandler = new StoreDataHandler(data);
                ChangeRecords <Supplier> dataList    = dataHandler.ObjectData <Supplier>();

                foreach (Supplier supplier in dataList.Deleted)
                {
                    db.Suppliers.Attach(supplier);
                    db.Suppliers.DeleteOnSubmit(supplier);
                }

                foreach (Supplier supplier in dataList.Updated)
                {
                    db.Suppliers.Attach(supplier);
                    db.Refresh(RefreshMode.KeepCurrentValues, supplier);
                }

                foreach (Supplier supplier in dataList.Created)
                {
                    supplier.TemporaryID = supplier.SupplierID;
                    db.Suppliers.InsertOnSubmit(supplier);
                }

                db.SubmitChanges();
            }
            catch (Exception e)
            {
                sr.Success = false;
                sr.Msg     = e.Message;
            }

            return(sr);
        }
Beispiel #29
0
        public AjaxStoreResult SaveCustomersWithoutConfirmation()
        {
            AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);

            try
            {
                NorthwindDataContext     db          = this.DBContext;
                StoreDataHandler         dataHandler = new StoreDataHandler(HttpContext.Request["data"]);
                ChangeRecords <Customer> data        = dataHandler.ObjectData <Customer>();

                foreach (Customer customer in data.Deleted)
                {
                    db.Customers.Attach(customer);
                    db.Customers.DeleteOnSubmit(customer);
                }

                foreach (Customer customer in data.Updated)
                {
                    db.Customers.Attach(customer);
                    db.Refresh(RefreshMode.KeepCurrentValues, customer);
                }

                foreach (Customer customer in data.Created)
                {
                    db.Customers.InsertOnSubmit(customer);
                }

                db.SubmitChanges();
            }
            catch (Exception e)
            {
                ajaxStoreResult.SaveResponse.Success = false;
                ajaxStoreResult.SaveResponse.Message = e.Message;
            }

            return(ajaxStoreResult);
        }
Beispiel #30
0
        public void ProcessRequest(HttpContext context)
        {
            Response sr = new Response(true);

            try
            {
                NorthwindDataContext     db          = new NorthwindDataContext();
                StoreDataHandler         dataHandler = new StoreDataHandler(context);
                ChangeRecords <Supplier> data        = dataHandler.ObjectData <Supplier>();

                foreach (Supplier supplier in data.Deleted)
                {
                    db.Suppliers.Attach(supplier);
                    db.Suppliers.DeleteOnSubmit(supplier);
                }

                foreach (Supplier supplier in data.Updated)
                {
                    db.Suppliers.Attach(supplier);
                    db.Refresh(RefreshMode.KeepCurrentValues, supplier);
                }

                foreach (Supplier supplier in data.Created)
                {
                    db.Suppliers.InsertOnSubmit(supplier);
                }

                db.SubmitChanges();
            }
            catch (Exception e)
            {
                sr.Success = false;
                sr.Message = e.Message;
            }

            sr.Write();
        }