Пример #1
0
        private void btnSaveHotLine_Click(object sender, EventArgs e)
        {
            TblConsultantLog cLog = new TblConsultantLog();

            cLog.AnswerRef = currentInfo.InfoTitle;
            cLog.ClientCode = currentClient.ClientCode;
            cLog.ClientID = currentClient.ClientID;
            cLog.ClientName = currentClient.ClientName;
            cLog.ConsType = ConsultantType.PhoneCall;
            cLog.CreateDate = DateTime.Now;
            cLog.Descriptions = txtSearch.Text;
            cLog.FinishDate = DateTime.Now;
            cLog.TargetType = ConsultantType.PhoneCall;
            cLog.ID = currentClient.ClientCode + currentUser.UserName + DateTime.Now.ToBinary().ToString();

            cLog.Question = txtSearch.Text;
            cLog.Status = ConsultantStatus.OK;
            cLog.TargetCount = 1;
            cLog.UserID = currentUser.UserID;
            cLog.UserName = currentUser.UserName;

            FrmSaveHotline frmSaveHotLine = new FrmSaveHotline(cLog);
            frmSaveHotLine.ShowDialog();
        }
Пример #2
0
        public APIResult UpdateConsultantLog(TblConsultantLog data)
        {
            APIResult res = new APIResult();
            using (Sonartez_server db = new Sonartez_server(connectionString))
            {
                var matchedObj = (from c in db.TblConsultantLog
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

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

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

                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.AnswerRef = data.AnswerRef;
                        matchedObj.ClientCode = data.ClientCode;
                        matchedObj.ClientID = data.ClientID;
                        matchedObj.ClientName = data.ClientName;
                        matchedObj.ConsType = data.ConsType;
                        matchedObj.CreateDate = data.CreateDate;
                        matchedObj.Descriptions = data.Descriptions;
                        matchedObj.FinishDate = data.FinishDate;
                        matchedObj.FinishType = data.FinishType;
                        matchedObj.Question = data.Question;
                        matchedObj.Status = data.Status;
                        matchedObj.SubmitDate = data.SubmitDate;
                        matchedObj.TargetCount = data.TargetCount;
                        matchedObj.TargetCountry = data.TargetCountry;
                        matchedObj.TargetEmail = data.TargetEmail;
                        matchedObj.TargetName = data.TargetName;
                        matchedObj.TargetPhoneNumber = data.TargetPhoneNumber;
                        matchedObj.TargetType = data.TargetType;
                        matchedObj.UserID = data.UserID;
                        matchedObj.UserName = data.UserName;
                        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;
        }
Пример #3
0
 partial void DeleteTblConsultantLog(TblConsultantLog instance);
Пример #4
0
 partial void UpdateTblConsultantLog(TblConsultantLog instance);
Пример #5
0
 partial void InsertTblConsultantLog(TblConsultantLog instance);
Пример #6
0
        public TblConsultantLog InsertOrUpdate(TblConsultantLog data)
        {
            Exception cex = null;
            TblConsultantLog res = null;
            var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString);
            using (Sonartez_server db = new Sonartez_server(conn))
            {
                var matchedObj = (from c in db.TblConsultantLog
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

                if (matchedObj == null)
                {
                    try
                    {
                        // does not exist
                        Table<TblConsultantLog> TblObj = db.TblConsultantLog;
                        data.UpdateDate = DateTime.Now;
                        data.SubmitDate = DateTime.Now;
                        data.IsDeleted = 0;
                        TblObj.InsertOnSubmit(data);
                        TblObj.Context.SubmitChanges();
                        res = data;
                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.AnswerRef = data.AnswerRef;
                        matchedObj.CreateDate = data.CreateDate;
                        matchedObj.ClientCode = data.ClientCode;
                        matchedObj.ClientID = data.ClientID;
                        matchedObj.ClientName = data.ClientName;
                        matchedObj.ConsType = data.ConsType;
                        matchedObj.CreateDate = data.CreateDate;
                        matchedObj.Descriptions = data.Descriptions;
                        matchedObj.Status = data.Status;
                        matchedObj.FinishDate = data.FinishDate;
                        matchedObj.FinishType = data.FinishType;
                        matchedObj.IsDeleted = data.IsDeleted;
                        matchedObj.Question = data.Question;
                        matchedObj.SubmitDate = data.SubmitDate;
                        matchedObj.TargetCount = data.TargetCount;
                        matchedObj.SubmitDate = data.SubmitDate;
                        matchedObj.TargetCountry = data.TargetCountry;
                        matchedObj.TargetEmail = data.TargetEmail;
                        matchedObj.TargetName = data.TargetName;
                        matchedObj.TargetPhoneNumber = data.TargetPhoneNumber;
                        matchedObj.TargetType = data.TargetType;
                        matchedObj.UserID = data.UserID;
                        matchedObj.UserName = data.UserName;
                        matchedObj.UpdateDate = DateTime.Now;
                        db.SubmitChanges();
                        res = matchedObj;

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

            }

            if (cex != null)
                throw cex;
            else
                return res;
        }
Пример #7
0
        private bool Delete(TblConsultantLog 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.TblConsultantLog
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

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

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