コード例 #1
0
        //Update a record
        public static int AddUpdateRecord(etblPropertyRoomsBiddingMap eobj, DataTable BidRange)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    SqlParameter[] MyParam = new SqlParameter[7];
                    MyParam[0]          = new SqlParameter("@BidRange", BidRange);
                    MyParam[0].TypeName = "[dbo].[BidRange]";
                    MyParam[1]          = new SqlParameter("@iPropId", eobj.iPropId);
                    MyParam[2]          = new SqlParameter("@iActionBy", eobj.iActionBy);
                    MyParam[3]          = new SqlParameter("@bCloseOut", eobj.bIsClosed);
                    MyParam[4]          = new SqlParameter("@bCTA", eobj.bCTA);
                    MyParam[5]          = new SqlParameter("@bCTD", eobj.bCTD);
                    MyParam[6]          = new SqlParameter("@typ", eobj.IsPublic ? 1 : 0);

                    db.Database.ExecuteSqlCommand("uspSaveRoomsBidding @BidRange, @iPropId, @iActionBy, @bCloseOut, @bCTA, @bCTD, @typ", MyParam);
                    retval = 1;
                }
                catch (Exception)
                {
                    retval = 0;
                    throw;
                }
            }
            return(retval);
        }
コード例 #2
0
        public ActionResult Rooms(string date, string typ, string pctype)
        {
            PropertyBiddingMapForOverview lst = new PropertyBiddingMapForOverview();
            etblPropertyRoomsBiddingMap   obj = new etblPropertyRoomsBiddingMap();

            lst = BL_tblPropertyRoomsBiddingMap.GetRecords(clsUtils.ConvertyyyymmddtoDateTime(date), Convert.ToInt32(Session["PropId"]), Convert.ToInt32(typ), pctype);
            if (lst.Self.Count > 0)
            {
                obj.JSONData        = OneFineRateAppUtil.clsUtils.ConvertToJson(lst.Self);
                obj.JSONDataOther   = OneFineRateAppUtil.clsUtils.ConvertToJson(lst.Other);
                obj.bCTA            = lst.Self[0].bCTA;
                obj.bCTD            = lst.Self[0].bCTD;
                obj.bIsClosed       = lst.Self[0].bIsClosed;
                obj.dtEffectiveDate = clsUtils.ConvertyyyymmddtoDateTime(date);
                obj.IsPublic        = lst.IsPublic;
                if (obj.dtEffectiveDate != null)
                {
                    obj.EffectiveDate = String.Format("{0:dd/MM/yyyy}", obj.dtEffectiveDate);
                }
            }
            else
            {
                obj.dtEffectiveDate = clsUtils.ConvertyyyymmddtoDateTime(date);
                obj.EffectiveDate   = String.Format("{0:dd/MM/yyyy}", obj.dtEffectiveDate);
            }


            return(PartialView("_PropertyRoomsBiddingMap", obj));
        }
コード例 #3
0
        public ActionResult UpdateRoomsBidding(etblPropertyRoomsBiddingMap eObj)
        {
            object result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    if (eObj.dtEffectiveDate.Date < DateTime.Now.AddDays(-7).Date)
                    {
                        result = new { st = 0, msg = "Please provide rooms discounts for this date in Bidding => Bulk Update screen first as this screen can only update discounts." };
                    }
                    else if (eObj.dtEffectiveDate.Date >= DateTime.Now.AddDays(-7).Date&& eObj.dtEffectiveDate.Date < DateTime.Now.Date)
                    {
                        result = new { st = 0, msg = "Data for past dates cannot be provided." };
                    }
                    else
                    {
                        bool bValid = true;
                        eObj.iPropId   = Convert.ToInt32(Session["PropId"]);
                        eObj.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;

                        DataTable  BidRange = new DataTable();
                        DataColumn col1     = null;
                        col1 = new DataColumn("dtEffectiveDate", typeof(DateTime));
                        BidRange.Columns.Add(col1);
                        col1 = new DataColumn("iDays", typeof(short));
                        BidRange.Columns.Add(col1);
                        col1 = new DataColumn("dDiscount", typeof(Decimal));
                        BidRange.Columns.Add(col1);
                        col1 = new DataColumn("iAmenityId1", typeof(Int32));
                        BidRange.Columns.Add(col1);
                        col1 = new DataColumn("iApplicabilityId1", typeof(short));
                        BidRange.Columns.Add(col1);
                        col1 = new DataColumn("iAmenityId2", typeof(Int32));
                        BidRange.Columns.Add(col1);
                        col1 = new DataColumn("iApplicabilityId2", typeof(short));
                        BidRange.Columns.Add(col1);

                        if (eObj.SelectedDiscounts != null)
                        {
                            decimal discount = 0;
                            JArray  jArray   = (JArray)JsonConvert.DeserializeObject(eObj.SelectedDiscounts.Replace("\\", "\""));
                            if (jArray != null)
                            {
                                foreach (var item in jArray)
                                {
                                    if (Convert.ToInt32(item["to"]) == 0)
                                    {
                                        bValid = false;
                                    }
                                    for (int i = Convert.ToInt32(item["from"]); i <= Convert.ToInt32(item["to"]); i++)
                                    {
                                        discount = string.IsNullOrEmpty(item["disc"].ToString()) ? Convert.ToDecimal("0") : Convert.ToDecimal(item["disc"]);
                                        DataRow dr = BidRange.NewRow();
                                        dr["dtEffectiveDate"]   = eObj.dtEffectiveDate;
                                        dr["iDays"]             = i;
                                        dr["dDiscount"]         = discount;
                                        dr["iAmenityId1"]       = Convert.ToInt32(item["amen1"]);
                                        dr["iApplicabilityId1"] = Convert.ToInt16(item["app1"]);
                                        dr["iAmenityId2"]       = Convert.ToInt32(item["amen2"]);
                                        dr["iApplicabilityId2"] = Convert.ToInt16(item["app2"]);
                                        BidRange.Rows.Add(dr);
                                    }
                                }
                            }
                        }
                        if (bValid)
                        {
                            int j = BL_tblPropertyRoomsBiddingMap.AddUpdateRecord(eObj, BidRange);
                            if (j == 1)
                            {
                                result = new { st = 1, msg = "Updated successfully." };
                            }
                            else
                            {
                                result = new { st = 0, msg = "Kindly try after some time." };
                            }
                        }
                        else
                        {
                            result = new { st = 0, msg = "Please provide rooms discounts for this date in Bidding => Bulk Update screen first as this screen can only update discounts." }
                        };
                    }
                }
                else
                {
                    string errormsg = "";
                    foreach (ModelState modelState in ViewData.ModelState.Values)
                    {
                        foreach (ModelError error in modelState.Errors)
                        {
                            errormsg += error.ErrorMessage;
                            errormsg += "</br>";
                        }
                    }

                    result = new { st = 0, msg = errormsg };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = "Kindly try after some time." };
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }