예제 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string   datepickerFromDate = txtFromDate.Text;
        DateTime dtFromDate         = DateTime.Now;

        DateTime.TryParse(datepickerFromDate, out dtFromDate);

        string   datepickerToDate = txtToDate.Text;
        DateTime dtToDate         = DateTime.Now;

        DateTime.TryParse(datepickerToDate, out dtToDate);
        int areaId    = int.Parse(ddlAreas.SelectedValue);
        int serviceId = int.Parse(ddlServices.SelectedValue);

        if (dtFromDate > dtToDate || string.IsNullOrEmpty(ddlPromtedSuppliers.SelectedValue) || ddlPromtedSuppliers.SelectedValue == "0")
        {
            return;
        }
        int supplierId = int.Parse(ddlPromtedSuppliers.SelectedValue);

        int itemId = Id;
        SupplierPromotedArea spa = new SupplierPromotedArea()
        {
            IsNewRecord    = true,
            PromotedAreaId = areaId,
            SupplierId     = supplierId,
            StartTime      = dtFromDate,
            EndTime        = dtToDate,
            Id             = itemId,
            ServiceId      = serviceId,
        };

        if (itemId == 0)// insert
        {
            spa.Insert();
        }
        else //update
        {
            spa.Update();
        }


        if (IsNewMode)
        {
            string successMessage = ResourceManagerAccessor.GetText("PromotedArea", @"MessageSupplierCreated");
            string url            = @"EditPromotedSuppliers.aspx?Id=" + spa.Id;
            url += @"&message-success=" + Server.UrlEncode(successMessage);
            Response.Redirect(url, true);
        }
        else
        {
            string successMessage = SuppliersStrings.GetText(@"MessageSupplierSaved");
            Master.MessageCenter.DisplaySuccessMessage(successMessage);
            LoadView();
        }
    }
예제 #2
0
 public static bool Delete(int promotedSupplierAreaId)
 {
     try
     {
         SupplierPromotedArea supplierPromotedArea = SupplierPromotedArea.FetchByID(promotedSupplierAreaId);
         supplierPromotedArea.Deleted = DateTime.Now;
         supplierPromotedArea.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #3
0
 protected void LoadView()
 {
     if (Id > 0)
     {
         SupplierPromotedArea supplierPromotedArea = SupplierPromotedArea.FetchByID(Id);
         if (supplierPromotedArea != null)
         {
             //txtBusinessName.Text = adCompany.BusinessName;
             ddlAreas.SelectedValue            = supplierPromotedArea.PromotedAreaId.ToString();
             ddlServices.SelectedValue         = supplierPromotedArea.ServiceId.ToString();
             ddlPromtedSuppliers.SelectedValue = supplierPromotedArea.SupplierId.ToString();
             txtFromDate.Text = supplierPromotedArea.StartTime.ToShortDateString();
             txtToDate.Text   = supplierPromotedArea.EndTime.ToShortDateString();
         }
     }
 }
예제 #4
0
    protected override void VerifyAccessToThisPage()
    {
        string[] permissions = Permissions.PermissionsForUser(SessionHelper.UserId());
        if (!permissions.Contains(Permissions.PermissionKeys.sys_perm))
        {
            Master.LimitAccessToPage();
        }
        IsNewMode = Request.QueryString[@"New"] != null;

        if (!IsNewMode)
        {
            if (int.TryParse(Request.QueryString[@"Id"], out Id))
            {
                SupplierPromotedArea supplierPromotedArea = SupplierPromotedArea.FetchByID(Id);
                if (supplierPromotedArea == null)
                {
                    Master.LimitAccessToPage();
                }
            }
        }
    }