Example #1
0
        public EnquiryBooking Insert(EnquiryBooking objEnquiryBooking)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                var result = new EnquiryBooking();

                IDbTransaction trn = connection.BeginTransaction();

                string sql = @"INSERT INTO EnquiryBooking(EnquiryRef,EnquiryDate,EnquiryClient,ClientTypeId,ModeofContactId,ProjectTypeId, 
                EnquiryReference,EnquiryContactNo,EnquiryEmail,EnquiryLocation,EnquiryDetails,EnquiryCancel,CreatedBy,CreatedDate,OrganizationId)
                VALUES(@EnquiryRef,@EnquiryDate,@EnquiryClient,@ClientTypeId,@ModeofContactId,@ProjectTypeId,@EnquiryReference,
                @EnquiryContactNo,@EnquiryEmail,@EnquiryLocation,@EnquiryDetails,0,@CreatedBy,@CreatedDate,@OrganizationId);
                SELECT CAST(SCOPE_IDENTITY() as int)";
                try
                {
                    int internalid = DatabaseCommonRepository.GetInternalIDFromDatabase(connection, trn, typeof(EnquiryBooking).Name, "0", 1);
                    objEnquiryBooking.EnquiryRef = internalid.ToString();

                    int id = connection.Query <int>(sql, objEnquiryBooking, trn).Single();
                    objEnquiryBooking.EnquiryId = id;
                    InsertLoginHistory(dataConnection, objEnquiryBooking.CreatedBy, "Create", "EnquiryBooking", id.ToString(), "0");
                    trn.Commit();
                }
                catch (Exception ex)
                {
                    trn.Rollback();
                    objEnquiryBooking.EnquiryId  = 0;
                    objEnquiryBooking.EnquiryRef = null;
                }
                return(objEnquiryBooking);
            }
        }
Example #2
0
        public ActionResult EnquiryBooking()
        {
            //ViewBag.Title = "Create";
            FillDropdowns();
            EnquiryBooking EnquiryBooking = new EnquiryBooking();

            EnquiryBooking.EnquiryRef  = new EnquiryBookingRepository().GetRefNo(EnquiryBooking);
            EnquiryBooking.EnquiryDate = DateTime.Now;
            return(View(EnquiryBooking));
        }
Example #3
0
        public string GetRefNo(EnquiryBooking objEnquiryBooking)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                string RefNo  = "";
                var    result = new EnquiryBooking();

                IDbTransaction trn = connection.BeginTransaction();

                try
                {
                    int internalid = DatabaseCommonRepository.GetInternalIDFromDatabase(connection, trn, typeof(EnquiryBooking).Name, "0", 0);
                    RefNo = internalid.ToString();
                    trn.Commit();
                }
                catch (Exception ex)
                {
                    trn.Rollback();
                }
                return(RefNo);
            }
        }
Example #4
0
        public ActionResult EnquiryBooking(EnquiryBooking model)
        {
            if (!ModelState.IsValid)
            {
                FillDropdowns();
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(View(model));
            }
            model.CreatedBy      = UserID.ToString();
            model.CreatedDate    = System.DateTime.Now;
            model.OrganizationId = OrganizationId;
            var repo = new EnquiryBookingRepository();
            //bool isexists = repo.IsFieldExists(repo.ConnectionString(), "EnquiryBooking", "SubName", model.SubName, null, null);
            //if (!isexists)
            {
                var result = new EnquiryBookingRepository().Insert(model);
                if (result.EnquiryId > 0)
                {
                    TempData["Success"]    = "Added Successfully!";
                    TempData["EnquiryRef"] = result.EnquiryRef;
                    return(RedirectToAction("EnquiryBooking"));
                }

                else
                {
                    TempData["error"]      = "Oops!!..Something Went Wrong!!";
                    TempData["EnquiryRef"] = null;
                    return(View("EnquiryBooking", model));
                }
            }
            //else
            //{

            //    TempData["error"] = "This Name Alredy Exists!!";
            //    TempData["SubRefNo"] = null;
            //    return View("Create", model);
            //}
        }