Esempio n. 1
0
        public TblClient InsertOrUpdate(TblClient data)
        {
            Exception cex = null;
            TblClient res = null;
            var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString);
            using (Sonartez_server db = new Sonartez_server(conn))
            {
                var matchedObj = (from c in db.TblClient
                                  where c.ClientID == data.ClientID
                                  select c).SingleOrDefault();

                if (matchedObj == null)
                {
                    try
                    {
                        // does not exist
                        Table<TblClient> TblObj = db.TblClient;
                        data.UpdateDate = DateTime.Now;
                        data.IsDeleted = 0;
                        TblObj.InsertOnSubmit(data);
                        TblObj.Context.SubmitChanges();
                        res = data;
                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.ClientCode = data.ClientCode;
                        matchedObj.ClientName = data.ClientName;
                        matchedObj.Descriptions = data.Descriptions;
                        matchedObj.LocationCode = data.LocationCode;
                        matchedObj.LocationName = data.LocationName;
                        matchedObj.UpdateDate = DateTime.Now;
                        matchedObj.IsDeleted = data.IsDeleted;
                        db.SubmitChanges();
                        res = matchedObj;

                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                    }
                }

            }

            if (cex != null)
                throw cex;
            else
                return res;
        }
Esempio n. 2
0
        public void LoadData(BBLConsultant cons)
        {
            //currentUser = new BBLUser().GetUser().FirstOrDefault();
            currentClient = new BBLClient().GetAll().FirstOrDefault();
            this.cons = cons;
            lstInfo = cons.GetAll();
            List<TblConsultantLog> lst = new List<TblConsultantLog>();

            lst.AddRange(lstInfo);

            lstInfo = lst;
            RunFilter();
        }
Esempio n. 3
0
        public void LoadData(BBLInfo _info)
        {
            string clientCode = ConfigurationManager.AppSettings["CLIENTCODE"];

            currentClient = new BBLClient().GetAll().FirstOrDefault(x=>x.ClientCode==clientCode);

            if (currentClient == null) {
                MessageBox.Show("Xác minh lại thiết lập Máy Trạm");
                new FrmConfig().ShowDialog();
            }

            this.info = _info;
            lstInfo = info.GetAll().Where(x=>x.IsDeleted==0);
            List<TblInfor> lst = new List<TblInfor>();

            lst.AddRange(lstInfo);

            lstInfo = lst;
            RunFilter();
        }
Esempio n. 4
0
        public void LoadData(BBLInfo _info)
        {
            if (currentUser.Permission == Permission.Normal) chkStatus.Enabled = false;

            string clientCode = ConfigurationManager.AppSettings["CLIENTCODE"];

            currentClient = new BBLClient().GetAll().FirstOrDefault(x => x.ClientCode == clientCode);

            if (currentClient == null)
            {
                MessageBox.Show("Xác minh lại thiết lập Máy Trạm");
                new FrmConfig().ShowDialog();
            }

            this.info = _info;
            lstInfo = info.GetAll().Where(x => x.IsDeleted == 0).ToList();
            //List<TblInfor> lst = new List<TblInfor>();

            //lst.AddRange(lstInfo);

            //lstInfo = lst;
            SettingAutoSuggest();
            RunFilter();
        }
Esempio n. 5
0
        public APIResult UpdateClient(TblClient data)
        {
            APIResult res = new APIResult();
            using (Sonartez_server db = new Sonartez_server(connectionString))
            {
                var matchedObj = (from c in db.TblClient
                                       where c.ClientID == data.ClientID
                                       select c).SingleOrDefault();

                if (matchedObj == null)
                {
                    try
                    {
                        // does not exist
                        Table<TblClient> TblObj = db.TblClient;
                        data.ServerUpdate = DateTime.Now;
                        TblObj.InsertOnSubmit(data);
                        TblObj.Context.SubmitChanges();

                        res.UpdateDate = data.UpdateDate.Value;
                        res.Success = true;

                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.ClientCode = data.ClientCode;
                        matchedObj.ClientName = data.ClientName;
                        matchedObj.Descriptions = data.Descriptions;
                        matchedObj.LocationCode = data.LocationCode;
                        matchedObj.LocationName = data.LocationName;
                        matchedObj.ServerUpdate = DateTime.Now;
                        matchedObj.UpdateDate = data.UpdateDate;
                        db.SubmitChanges();

                        res.UpdateDate = data.ServerUpdate.Value;
                        res.Success = true;
                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }

            }
            return res;
        }
Esempio n. 6
0
 partial void DeleteTblClient(TblClient instance);
Esempio n. 7
0
 partial void UpdateTblClient(TblClient instance);
Esempio n. 8
0
 partial void InsertTblClient(TblClient instance);
Esempio n. 9
0
        private bool Delete(TblClient data)
        {
            Exception cex = null;
            bool res = false;
            var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString);
            using (Sonartez_server db = new Sonartez_server(conn))
            {
                var matchedObj = (from c in db.TblClient
                                  where c.ClientID == data.ClientID
                                  select c).SingleOrDefault();

                if (matchedObj != null)
                {
                    try
                    {
                        // does not exist
                        db.TblClient.DeleteOnSubmit(matchedObj);
                        db.SubmitChanges();
                        res = true;
                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                        res = false;
                    }
                }
                else
                {
                    res = true;
                }
            }

            if (cex != null)
                throw cex;
            else
                return res;
        }