Ejemplo n.º 1
0
        private void GetBlockedDaysForCalendar(DateTime startDate, DateTime endDate)
        {
            var blockedDays = new EBlockedDay[0];

            var role = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole;

            if (role.CheckRole((long)Roles.FranchisorAdmin))
            {
                blockedDays = GetBlockedDayForCalendar(0, startDate.ToShortDateString(), endDate.ToShortDateString(), "Franchisor").ToArray();
            }
            else if (role.CheckRole((long)Roles.FranchiseeAdmin))
            {
                blockedDays = GetBlockedDayForCalendar(role.OrganizationRoleUserId, startDate.ToShortDateString(), endDate.ToShortDateString(), "Franchisee").ToArray();
            }


            if (blockedDays.Length > 0)
            {
                for (int count = 0; count < blockedDays.Length; count++)
                {
                    string blockedReason = string.Empty;

                    if ((blockedDays[count].IsGlobal == false) && (role.CheckRole((long)Roles.FranchisorAdmin)))
                    {
                        string controlID = "\"BlockedDay" + blockedDays[count].BlockedDayID + "\"";

                        string franchisee = string.Empty;
                        for (int i = 0; i < blockedDays[count].BlockDayFranchisee.Count; i++)
                        {
                            if (franchisee != string.Empty)
                            {
                                franchisee = franchisee + "<br>" + (i + 1) + ": " + blockedDays[count].BlockDayFranchisee[i].Franchisee.Name;
                            }
                            else
                            {
                                franchisee = (i + 1) + ": " + blockedDays[count].BlockDayFranchisee[i].Franchisee.Name;
                            }
                        }
                        franchisee = "\"" + franchisee + " \"";
                        string blockedDayDescription = franchisee + "," + controlID;
                        blockedReason = "<a  onmouseout='hideTipBubble(\"BlockedDay\")'   onmouseover='ShowBlockedDayFranchisee(" + blockedDayDescription + ")'> <img src='../Images/block-square.gif' />  " + blockedDays[count].BlockedReason + "</a>";
                    }

                    else
                    {
                        blockedReason = "<img src='../Images/block-square.gif' /> " + blockedDays[count].BlockedReason;
                    }


                    _tblAppointments.Rows.Add(new object[] { "BlockedDay" + blockedDays[count].BlockedDayID.ToString(), "BlockedDay", blockedReason, blockedDays[count].BlockedDate, string.Empty });
                }
            }
        }
Ejemplo n.º 2
0
    protected void ibtnsave_Click(object sender, ImageClickEventArgs e)
    {
        var         otherDal    = new OtherDAL();
        EBlockedDay objBlockday = new EBlockedDay
        {
            BlockedDate   = hfBlockDate.Value,
            BlockedReason = txtBlockReason.Text,
            IsActive      = true
        };

        var sessionContext = IoC.Resolve <ISessionContext>();

        //TODO: call by javascript
        EBlockedDayFranchisee[] objBlockdayFranchisee = GetSelectedFranchisee();


        if ((sessionContext.UserSession.CurrentOrganizationRole.CheckRole((long)Roles.FranchisorAdmin)) && ((objBlockdayFranchisee.Length == grdFranchisee.Rows.Count) || (objBlockdayFranchisee.Length == 0)))
        {
            objBlockday.IsGlobal = true;
        }
        else if (sessionContext.UserSession.CurrentOrganizationRole.CheckRole((long)Roles.FranchiseeAdmin))
        {
            objBlockday.IsGlobal = false;
        }


        objBlockday.BlockDayFranchisee = objBlockdayFranchisee.ToList();

        Int64 returnresult = otherDal.SaveBlockedDay(objBlockday, Convert.ToInt32(EOperationMode.Insert));

        if (returnresult == 0)
        {
            returnresult = 9999990;
        }

        hfBlockDate.Value   = "";
        txtBlockDate.Text   = "";
        txtBlockReason.Text = "";
        //setView(ViewState["ViewType"].ToString());

        CheckBox chk = (CheckBox)grdFranchisee.HeaderRow.FindControl("chkboxheader");

        System.Text.StringBuilder strJsCloseWindow = new System.Text.StringBuilder();
        strJsCloseWindow.Append(" <script language = 'Javascript'> document.getElementById('" + chk.ClientID + "').checked=false;GridMasterCheck(); </script>");
        ClientScript.RegisterStartupScript(typeof(string), "JSCode", strJsCloseWindow.ToString());
    }