//Update a record
        public static int UpdateRecord(etblPropertyBasicBiddingMapForOverview eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    DataTable  BidRange = new DataTable();
                    DataColumn col      = null;
                    col = new DataColumn("dtEffectiveDate", typeof(DateTime));
                    BidRange.Columns.Add(col);

                    DataRow drBidRange = BidRange.NewRow();
                    drBidRange["dtEffectiveDate"] = eobj.Self.dtEffectiveDate;
                    BidRange.Rows.Add(drBidRange);

                    SqlParameter[] MyParam = new SqlParameter[8];
                    MyParam[0]          = new SqlParameter("@BidDates", BidRange);
                    MyParam[0].TypeName = "[dbo].[BidDates]";
                    MyParam[1]          = new SqlParameter("@iPropId", eobj.Self.iPropId);
                    MyParam[2]          = new SqlParameter("@bCloseOut", eobj.Self.bIsClosed);
                    MyParam[3]          = new SqlParameter("@bCTA", eobj.Self.bCTA);
                    MyParam[4]          = new SqlParameter("@bCTD", eobj.Self.bCTD);
                    MyParam[5]          = new SqlParameter("@iActionBy", eobj.Self.iActionBy);
                    MyParam[6]          = new SqlParameter("@dDiscount", eobj.Self.dBasicDiscount == null ? (object)DBNull.Value : eobj.Self.dBasicDiscount);
                    MyParam[7]          = new SqlParameter("@typ", eobj.IsPublic ? 1 : 0);
                    db.Database.ExecuteSqlCommand("uspSaveBasicDisc @BidDates, @iPropId, @iActionBy, @bCloseOut, @bCTA, @bCTD, @dDiscount, @typ", MyParam);
                    retval = 1;
                }
                catch (Exception) { }
            }
            return(retval);
        }
Ejemplo n.º 2
0
        public ActionResult UpdateBasicBidding(etblPropertyBasicBiddingMapForOverview eObj)
        {
            object result = null;

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

                        int j = BL_tblPropertyBasicBiddingMap.UpdateRecord(eObj);
                        if (j == 1)
                        {
                            result = new { st = 1, msg = "Updated successfully." };
                        }
                        else
                        {
                            result = new { st = 0, msg = "Kindly try after some time." };
                        }
                    }
                }
                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));
        }
Ejemplo n.º 3
0
        public ActionResult Basic(string date, string typ, string pctype)
        {
            etblPropertyBasicBiddingMapForOverview obj = new etblPropertyBasicBiddingMapForOverview();

            obj = BL_tblPropertyBasicBiddingMap.GetSingleRecordById(clsUtils.ConvertyyyymmddtoDateTime(date), Convert.ToInt32(Session["PropId"]), Convert.ToInt32(typ), pctype);
            //if (obj.dtEffectiveDate != null)
            //{
            //    obj.EffectiveDate = String.Format("{0:dd/MM/yyyy}", obj.dtEffectiveDate);
            //}
            //else
            //{
            obj.Self.dtEffectiveDate = clsUtils.ConvertyyyymmddtoDateTime(date);
            obj.Self.EffectiveDate   = String.Format("{0:dd/MM/yyyy}", obj.Self.dtEffectiveDate);
            //}

            return(PartialView("_PropertyBasicBiddingMap", obj));
        }
        //get single record
        public static etblPropertyBasicBiddingMapForOverview GetSingleRecordById(DateTime Date, int PropId, int typ, string corporateOrPublic)
        {
            etblPropertyBasicBiddingMapForOverview OBJ        = new etblPropertyBasicBiddingMapForOverview();
            etblPropertyBasicBiddingMap            eobjPublic = new etblPropertyBasicBiddingMap();
            etblPropertyBasicBiddingMap            eobjCorp   = new etblPropertyBasicBiddingMap();

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                // Getting Data for Public rates
                {
                    var dbobj = db.tblPropertyBasicBiddingMaps.SingleOrDefault(u => u.iPropId == PropId && u.dtEffectiveDate == Date);
                    if (dbobj != null)
                    {
                        eobjPublic = (etblPropertyBasicBiddingMap)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobjPublic);
                    }
                }

                // Getting Data for Corp rates
                {
                    var dbobj = db.tblPropertyBasicBiddingMapCorps.SingleOrDefault(u => u.iPropId == PropId && u.dtEffectiveDate == Date);
                    if (dbobj != null)
                    {
                        eobjCorp = (etblPropertyBasicBiddingMap)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobjCorp);
                    }
                }
            }

            if (string.IsNullOrEmpty(corporateOrPublic))
            {
                if (typ % 2 == 1) // Public discounts as main. Corporate as other.
                {
                    OBJ.Self     = eobjPublic;
                    OBJ.Other    = eobjCorp;
                    OBJ.IsPublic = true;
                }
                else
                {
                    OBJ.Self     = eobjCorp;
                    OBJ.Other    = eobjPublic;
                    OBJ.IsPublic = false;
                }
            }

            else if (corporateOrPublic == null && typ == 9)
            {
                OBJ.Self     = eobjPublic;
                OBJ.Other    = eobjCorp;
                OBJ.IsPublic = true;
            }
            else
            {
                if (corporateOrPublic == "p")
                {
                    OBJ.Self     = eobjPublic;
                    OBJ.Other    = eobjCorp;
                    OBJ.IsPublic = true;
                }
                else
                {
                    OBJ.Self     = eobjCorp;
                    OBJ.Other    = eobjPublic;
                    OBJ.IsPublic = false;
                }
            }

            return(OBJ);
        }