コード例 #1
0
        public VisitModel GetVisitDetails(int id)
        {
            ShomaRMEntities db    = new ShomaRMEntities();
            VisitModel      model = new VisitModel();

            var getVisitDet = db.tbl_Visit.Where(p => p.VisitID == id).FirstOrDefault();

            if (getVisitDet != null)
            {
                DateTime?visitDateTime = null;
                try
                {
                    visitDateTime = Convert.ToDateTime(getVisitDet.VisitDateTime);
                }
                catch
                {
                }

                model.VisitID           = getVisitDet.VisitID;
                model.ProspectID        = getVisitDet.ProspectID;
                model.VisitDateTimeText = visitDateTime == null ? "" : visitDateTime.Value.ToString("MM/dd/yyy");
                model.ResultCode        = getVisitDet.ResultCode;
                model.VisitNumber       = getVisitDet.VisitNumber;
                model.Details           = getVisitDet.Details;
                model.Activity          = getVisitDet.Activity;
                model.VisitIncharge     = getVisitDet.VisitIncharge;

                model.VisitSlot = getVisitDet.VisitSlot;
            }
            return(model);
        }
コード例 #2
0
        public List <VisitModel> GetVisitList(long ProspectID)
        {
            ShomaRMEntities   db    = new ShomaRMEntities();
            List <VisitModel> lstpr = new List <VisitModel>();

            try
            {
                DataTable dtTable = new DataTable();
                dtTable.Clear();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetVisitList";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter paramF = cmd.CreateParameter();
                    paramF.ParameterName = "ProspectID";
                    paramF.Value         = ProspectID;
                    cmd.Parameters.Add(paramF);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                foreach (DataRow dr in dtTable.Rows)
                {
                    VisitModel pr            = new VisitModel();
                    DateTime?  visitDateTime = null;
                    try
                    {
                        visitDateTime = Convert.ToDateTime(dr["VisitDateTime"].ToString());
                    }
                    catch
                    {
                    }
                    pr.VisitID           = Convert.ToInt64(dr["VisitID"].ToString());
                    pr.ProspectID        = Convert.ToInt64(dr["ProspectID"].ToString());
                    pr.ResultCode        = dr["ResultCode"].ToString();
                    pr.Details           = dr["Details"].ToString();
                    pr.Activity          = Convert.ToInt32(dr["Activity"].ToString());
                    pr.VisitNumber       = Convert.ToInt32(dr["VisitNumber"].ToString());
                    pr.VisitSlot         = Convert.ToInt32(dr["VisitSlot"].ToString());
                    pr.VisitInchargeText = dr["VisitInchargeText"].ToString();
                    pr.VisitDateTimeText = visitDateTime == null ? "" : visitDateTime.Value.ToString("MM/dd/yyy");
                    lstpr.Add(pr);
                }
                db.Dispose();
                return(lstpr.ToList());
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
コード例 #3
0
        public string SaveUpdateVisit(VisitModel model)
        {
            ShomaRMEntities db      = new ShomaRMEntities();
            string          msg     = "";
            var             visitID = db.tbl_Visit.Where(p => p.VisitID == model.VisitID).FirstOrDefault();

            if (model.VisitID == 0)
            {
                var saveVisit = new tbl_Visit()
                {
                    VisitID       = model.VisitID,
                    ProspectID    = model.ProspectID,
                    VisitDateTime = model.VisitDateTime,
                    ResultCode    = model.ResultCode,
                    VisitNumber   = model.VisitNumber,
                    Details       = model.Details,
                    Activity      = model.Activity,
                    VisitIncharge = model.VisitIncharge,
                    VisitSlot     = model.VisitSlot,
                };
                db.tbl_Visit.Add(saveVisit);
                db.SaveChanges();


                msg = "Visit Saved Successfully";
            }
            else
            {
                var visitData = db.tbl_Visit.Where(p => p.VisitID == model.VisitID).FirstOrDefault();
                if (visitData != null)
                {
                    visitData.VisitID       = model.VisitID;
                    visitData.ProspectID    = model.ProspectID;
                    visitData.VisitDateTime = model.VisitDateTime;
                    visitData.ResultCode    = model.ResultCode;
                    visitData.VisitNumber   = model.VisitNumber;
                    visitData.Details       = model.Details;
                    visitData.Activity      = model.Activity;
                    visitData.VisitIncharge = model.VisitIncharge;
                    visitData.VisitSlot     = model.VisitSlot;
                }
                db.SaveChanges();
                msg = "Visit Updated Successfully";
            }

            db.Dispose();
            return(msg);
        }