示例#1
0
        protected void uiLinkButtonSaveRoom_Click(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                Member member = BLL.Member.CurrentMember;
                Room room = new Room();
                if (!room.LoadByPrimaryKey(Convert.ToInt32(hdnRoomID.Value)))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . لا توجد غرفة بهذا الإسم.'); });", true);
                    return;
                }

                room.Name = txtNewName.Text;
                room.Save();

                //delete old records
                BLL.RoomType bllRoomType = new RoomType();
                bllRoomType.DeleteOldType(room.RoomID);

                BLL.RoomTypeSpecDuration bllTypeSpecDuration = new RoomTypeSpecDuration();
                bllTypeSpecDuration.LoadByRoomTypeSpecID(Convert.ToInt32(lstTypes.SelectedValue));
                room.RoomType.RoomTypeSpecDurationID = bllTypeSpecDuration.ID;
                room.RoomType.CreateBy = BLL.Member.CurrentMember.MemberID;
                room.RoomType.StartDate = DateTime.Now;
                room.RoomType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(lstTypeDuration.SelectedValue));
                room.RoomType.OldName = txtRoomName.Text;
                room.RoomType.Save();

                uiPanelSuccess.Visible = true;
                txtRoomName.Text = "";
                txtNewName.Text = "";

                // log
                BLL.MemberLog log = new BLL.MemberLog();
                log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeRoomType() { RoomName = room.Name,OldName=txtRoomName.Text, NewTypeName = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Name, NewTypeExpiryDate = room.RoomType.EndDate, Points = 0 }, null, room.RoomID);
                Chat2Connect.usercontrols.RoomTypes.NotifyRoom(room, bllTypeSpecDuration);
            }
        }
示例#2
0
        protected void uiLinkButtonConfirm_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            if (user.PasswordQuestion == uiDropDownListQuestion.SelectedValue && BLL.Member.CurrentMember.Answer == uiTextBoxAnswer.Text.Trim())
            {
                if (!String.IsNullOrEmpty(hdnRoom.Value))
                {
                    Room room = new Room();
                    room.LoadByPrimaryKey(Convert.ToInt32(hdnRoom.Value));

                    try
                    {
                        int durationID = Convert.ToInt32(hdnDuration.Value);
                        int specID = Convert.ToInt32(hdnSpec.Value);
                        BLL.RoomTypeSpecDuration bllRoomTypeSpecDuration = new RoomTypeSpecDuration();
                        bllRoomTypeSpecDuration.Where.TypeDurationID.Value = durationID;
                        bllRoomTypeSpecDuration.Where.RoomTypeSpecID.Value = specID;
                        bllRoomTypeSpecDuration.Query.Load();
                        int points = bllRoomTypeSpecDuration.Points;
                        if (BLL.Member.CurrentMember.Credit_Point < points)
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                            return;
                        }

                        BLL.Member.CurrentMember.Credit_Point -= points;
                        BLL.Member.CurrentMember.Save();

                        //delete old records
                        BLL.RoomType bllRoomType = new RoomType();
                        bllRoomType.DeleteOldType(room.RoomID);

                        room.RoomType.RoomTypeSpecDurationID = bllRoomTypeSpecDuration.ID;
                        room.RoomType.CreateBy = BLL.Member.CurrentMember.MemberID;
                        room.RoomType.StartDate = DateTime.Now;
                        room.RoomType.EndDate = DateTime.Now.AddMonths(bllRoomTypeSpecDuration.TypeDuration.MonthesNumber);
                        room.RoomType.Save();

                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Success1", @"$(document).ready(function () { notify('success', 'تم ترقية الغرفة بنجاح.'); });", true);

                        BLL.MemberLog log = new BLL.MemberLog();
                        log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeRoomType() { RoomName = room.Name, NewTypeName = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Name, NewTypeExpiryDate = room.RoomType.EndDate, Points = points }, null, room.RoomID);

                        NotifyRoom(room, bllRoomTypeSpecDuration);
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Error11", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Error4", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Error5", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك تأكد من السؤال والإجابة السرى.'); });", true);
                return;
            }
        }