Telerik Forums
UI for ASP.NET AJAX Forum
10 answers
301 views
Hello,

I've been facing a bug in the filter textboxes of the radgrid as following.

The Problem:
When the user press Enter key on any text box of the filter textboxes it will always display the filter menu of the first column.

Debugging:
After doing some debugging, I noticed that the filter image is of type "Submit" which the browser considers the submit button of the form and invokes it, so while there are no submit buttons on the form, the onclick event of the filter image is invoked resulting in the menu displayed by mistake.
In FireFox, the menu is displayed at position 0,0.
In IE, the menu is displayed relative to where the mouse positioned.

To Reproduce:
1- Put a radgrid in a webform page while flitering is enabled and do set autopostbackonfilter=false, don't put any other elements in the page, to be precise no submit buttons.
2- Focus on any of the filtering textboxes and hit enter.



Tsvetina
Telerik team
 answered on 08 Mar 2012
1 answer
184 views
I have a grid that is grouped by one field and has as its rightmost column a template column that contains a user control.
This user control just renders as a table with one row and a not-fixed number of columns, the cells containing an 'X' character or a space. Nothing fancy.
My trouble is aligning this table to the right.
In IE9 i can't get it to align to the right. In IE9 compatabilty mode the grid rows align properly, the header row doesn't.
In PDF export the table never aligns to the right; in Word export, it does so nicely.
I tried different style attributes on different levels, wrapping the table in a <div> element, to no avail.
There must be something i missed. Can someone point me in the right direction?
Galin
Telerik team
 answered on 08 Mar 2012
3 answers
154 views
I'm trying to implement hierarchial grid client update based on events I get from server.

JSON serialized array of objects is received from server and bound to grid with set_dataSource() either on MasterTableView or on one of detailTables. The problem is - respective detail tables only appear for rows that were bound to master table on server side. 
E.g. if I bind array of 0 records to masterTable on server-side and bind array of 3 records on client-side then - get_detailTables().length returns 0. If I bind 2 records on server side and 5 records on client side then - get_detailTables().length returns 2. Of course UI doesn't show that newly added rows can be expanded too. I'm using HierarchyLoadMode="Client" for master table.

Is there a way to workaround this and have detail tables created appropriately without additional server calls from grid?
Radoslav
Telerik team
 answered on 08 Mar 2012
1 answer
108 views
Hi all ..
briefly talk about my project , i want design  my asp.net app view  like win desktop .. therefore i use radwindow like telerik ex. http://demos.telerik.com/aspnet-ajax/window/examples/radwindowandmdi/defaultcs.aspx
its work perfecly .. but i can't put my icons  as i want  to my restriction zone .. i tried  repeater , datalist , and finally radlistview but i couldnt..i getting my menu values from db  ..

looks like;
http://www.yuklelan.com/images/yHMhp.jpg
and one more thing .. ; Is it possible to drag and drop in radlistview ?



now my app looks like ;http://www.yuklelan.com/images/J5EXi.jpg
Tsvetina
Telerik team
 answered on 08 Mar 2012
1 answer
126 views
Hi

Please let me know can i make a chart similar to attached one.

I need exactly the same.

Please let me know how can i implement this.

Thanks
Gautam
Yavor
Telerik team
 answered on 08 Mar 2012
3 answers
119 views
Hi,

I'm trying to get the checkbox reference which is inside the grid using the property UniqueName.
It returns me this ctl01$ctl03$chk which is actually the name of the control rather than the id.

I noticed that the id is exactly the same, just that the $ symbol is replaced with _
which means the id is ctl01_ctl03_chk

I just need some confirmation that the only difference with name and id is the symbol $ and _
because i replaced the symbol $ with _ in order to get the reference of the checkbox.

Is this advisable? I'm just concern that in future telerik might use some kind of other symbols that might
render my code useless. Please help.
 
Regards,
Dexter
Jayesh Goyani
Top achievements
Rank 2
 answered on 08 Mar 2012
3 answers
2.8K+ views
I'm using The Q3 2010 Scheduler control with a Web Service data source, in  class MyDbSchedulerProvider
 public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)
 {
      User objUser = (User)HttpContext.Current.Session["User"];
}

in function GetAppointments i'm use object HttpContext.Current.Session, Minor run all good when !isPosback, but when my execute event Update then HttpContext.Current.Session is null.
please help me.
thanks!



using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using Telerik.Web.UI;
using WebLibs;
using System.Data;
using EWorking.Scheduler;
using EWorking.CRM;
using HRMS.Utility;
using System.Web;
using System.Web.Services;
using System.Web.SessionState;

namespace EWorking.Scheduler
{
    public class MyDbSchedulerProvider : DbSchedulerProviderBase  
    {
        private string strUsername = string.Empty;

        public string Username
        {
            get { return strUsername; }
            set { strUsername = value; }
        }

        private IDictionary<int, Resource> _teachers;
        private IDictionary<int, Resource> _students;

        private IDictionary<int, Resource> Teachers
        {
            get
            {
                if (_teachers == null)
                {
                    _teachers = new Dictionary<int, Resource>();
                    foreach (Resource teacher in LoadTeachers())
                    {
                        _teachers.Add((int)teacher.Key, teacher);
                    }
                }

                return _teachers;
            }
        }

        private IDictionary<int, Resource> Students
        {
            get
            {
                _students = new Dictionary<int, Resource>();
                foreach (Resource student in LoadStudents())
                {
                    _students.Add((int)student.Key, student);
                }

                return _students;
            }
        }

        public MyDbSchedulerProvider()
        {
        }

        public MyDbSchedulerProvider(string strUser)
        {
            Username = strUser;
        }

        public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)
        {
            List<Appointment> appointments = new List<Appointment>();
            IData objData = new IData();
            try
            {
                objData.Connect();
                SCHAppointment objApp = new SCHAppointment();
                objApp.DataObject = objData;
                int intStatus = 1;
                if (HttpContext.Current.Session["MD_Scheduler_Status"] != null)
                    intStatus = Convert.ToInt16(HttpContext.Current.Session["MD_Scheduler_Status"]);
                IDataReader objReader = objApp.GetList(Username, intStatus, "");
                owner.Culture = ResxManager.CurrentCultureInfo;
                using (IDataReader reader = objReader)
                {
                    while (reader.Read())
                    {
                        Appointment apt = owner.CreateAppointment();
                        apt.Owner = owner;
                        apt.ID = reader["AppID"];
                        apt.Subject = Convert.ToString(reader["Subject"]);
                        apt.Start = DateTime.SpecifyKind(Convert.ToDateTime(reader["Start"]), DateTimeKind.Utc);
                        apt.End = DateTime.SpecifyKind(Convert.ToDateTime(reader["End"]), DateTimeKind.Utc);
                        apt.RecurrenceRule = Convert.ToString(reader["RecurrenceRule"]);
                        apt.RecurrenceParentID = reader["RecurrenceParentId"] == DBNull.Value ? null : reader["RecurrenceParentId"];

                        if (apt.RecurrenceParentID != null)
                        {
                            apt.RecurrenceState = RecurrenceState.Exception;
                        }
                        else
                            if (apt.RecurrenceRule != string.Empty)
                            {
                                apt.RecurrenceState = RecurrenceState.Master;
                            }
                        //apt.BackColor = System.Drawing.Color.Red;
                        //apt.BorderColor = System.Drawing.Color.Blue;

                        //apt.ForeColor = System.Drawing.Color.Red;
                        //apt.Owner.Height = System.Web.UI.WebControls.Unit.Pixel(100);

                        //LoadResources(apt);
                        appointments.Add(apt);
                    }
                }
            }
            catch
            {
            }
            finally
            {
                objData.DeConnect();
            }
            return appointments;
        }

        public void UpdateFull(int intAppID, string strSubject, DateTime dtmStart, DateTime dtmEnd, string strRecurrenceRule, int intRecurrenceParentID, bool bolShareAll, string strPlace, int intProcess, int intPriority, int intType, bool bolGroup, string strOwnerUsername, string strObjectName, int intAccountID, string strLstContact, int intEntityID, int intOwner, bool bolExistCRM, string strUserShare, int intMaxUserShare)
        {
            string str = Username;
            MySchedulerInfo objS = new MySchedulerInfo();
            
            IDbTransaction objTran = null;
            IData objData = new IData();
            SCHAppointment objMain = new SCHAppointment();
            try
            {

                objData.Connect();
                WebLibs.User objUser = (WebLibs.User)HttpContext.Current.Session["User"];
                objMain.AppID = intAppID;
                if (objMain.LoadByPrimaryKeys())
                {
                    objMain.Subject = strSubject;
                    objMain.Start = dtmStart;
                    objMain.End = dtmEnd;
                    objMain.RecurrenceRule = strRecurrenceRule;
                    objMain.RecurrenceParentID = intRecurrenceParentID;

                    objTran = objData.GetConnection().BeginTransaction();
                    objData.Transaction = objTran;
                    objMain.DataObject = objData;
                    objMain.Username = objUser.strUsername;
                    objMain.IsShareAll = bolShareAll;
                    objMain.UserShare = strUserShare;
                    objMain.MaxUsesrShare = intMaxUserShare;
                    objMain.Place = strPlace;
                    if (intProcess > 0)
                        objMain.ProgressID = intProcess;

                    objMain.PriorityID = intPriority;
                    objMain.AppType = intType;
                    if (bolExistCRM && intEntityID > 0)
                    {
                        CRMENTITIES objEntity = new CRMENTITIES();
                        objEntity.DataObject = objData;
                        objEntity.CREATEDUSER = objUser.strUsername;
                        if (!bolGroup)
                        {
                            GlobalFunction objFun = new GlobalFunction();
                            if (strOwnerUsername != "")
                                objEntity.OWNERID = Convert.ToInt32(objFun.GetUserInfo(strOwnerUsername).Rows[0]["UserID"]);
                        }
                        else
                            if (intOwner > 0)
                                objEntity.OWNERID = intOwner;

                        objEntity.MODULEID = CRMENTITIES.Activity;
                        objMain.EntityID = Convert.ToInt32(objEntity.Insert());
                        CRMRELATEDLIST objRELATEDLIST = new CRMRELATEDLIST();
                        objRELATEDLIST.DataObject = objData;
                        if (strObjectName != "")
                        {
                            objMain.RELATEDENTITYID = intAccountID;
                            objMain.RELATEDENTITYNAME = strObjectName;
                        }
                        string[] arrContact = strLstContact.Split(',');
                        for (int i = 0; i < arrContact.Length; i++)
                        {
                            objRELATEDLIST.ENTITYID = objMain.EntityID;
                            objRELATEDLIST.RELATEDENTITYID = Convert.ToInt32(arrContact[i]);
                            objRELATEDLIST.Insert();
                        }
                        objRELATEDLIST.ENTITYID = objMain.EntityID;
                        objRELATEDLIST.RELATEDENTITYID = intEntityID;
                        objRELATEDLIST.Insert();
                    }
                    objMain.Update();
                    if (!AddGuest(intAppID, objData, objMain.IsShareAll, objMain.UserShare, objMain.MaxUsesrShare))
                    {
                        objTran.Rollback();
                        return;
                    }
                    objTran.Commit();
                }
            }
            catch
            {
                objTran.Rollback();
            }
            finally
            {
                objData.DeConnect();
            }
            //Cache.Remove("Widget_Scheduler_" + User.strUsername);
        }   

        private string LoadShare(int intAppID)
        {
            string strResult = "";
            try
            {
                SCHAppointmentShare objAppShare = new SCHAppointmentShare();
                DataTable dt = new DataTable();
                dt = objAppShare.GetByID(intAppID);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    strResult += "<div><input checked='checked' type='checkbox' name='chkUserSharer' value='" + dt.Rows[i]["Username"] + "' />" + dt.Rows[i]["Username"] + " - " + dt.Rows[i]["Fullname"] + "</div>";
                }
            }
            catch (Exception objEx)
            {
                new SystemMessage("L?i khi l?y danh sách User du?c share!", "", "Controls_MD_Scheduler_Appointment.LoadShare(int intAppID)<br />ERROR: " + objEx.ToString());
            }
            return strResult;
        }
        public string[] GetData(int intAppID, bool ExistCRM)
        {
            string[] arrResult = new string[13];
            try
            {
                SCHAppointment objMain = new SCHAppointment();
                objMain.AppID = intAppID;

                if (objMain.LoadByPrimaryKeys())
                {
                    //LoadDiscuss(objMain.AppID);
                    //LoadInfoUser(objMain.AppID);
                    arrResult[0] = objMain.IsShareAll.ToString().ToLower();
                    arrResult[1] = objMain.Place;
                    if (objMain.ProgressID > 0)
                        arrResult[2] = objMain.ProgressID.ToString();
                    if (objMain.PriorityID > 0)
                        arrResult[3] = objMain.PriorityID.ToString();
                    if (objMain.AppType > 0)
                    {
                        arrResult[4] = objMain.AppType.ToString();
                    }

                    if (objMain.EntityID > 0 && ExistCRM)
                    {
                        CRMENTITIES objEntity = new CRMENTITIES();
                        objEntity.ENTITYID = objMain.EntityID;
                        if (objEntity.LoadByPrimaryKeys())
                        {
                            arrResult[11] = objEntity.UserType.ToString();
                            if (objEntity.UserType)
                                arrResult[7] = objEntity.OWNERID.ToString();
                            else
                            {
                                arrResult[5] = objEntity.Username;
                                arrResult[6] = objEntity.Fullname;
                            }
                        }
                        CRMRELATEDLIST objRELATEDLIST = new CRMRELATEDLIST();
                        DataTable dtContactList = objRELATEDLIST.GetRelatedList(objMain.EntityID, CRMENTITIES.Contact);
                        for (int i = 0; i < dtContactList.Rows.Count; i++)
                        {
                            //if (lstContact.Items.FindByValue(dtContactList.Rows[i]["ContactID"].ToString()) == null && lstContact.Items.FindByValue(intEntityID.ToString()) == null)
                            //    lstContact.Items.Add(new ListItem(dtContactList.Rows[i]["Firstname"] + " " + dtContactList.Rows[i]["Lastname"], dtContactList.Rows[i]["ContactID"].ToString()));
                        }
                        arrResult[8] = objMain.RELATEDENTITYNAME;//objectName
                        arrResult[9] = objMain.RELATEDENTITYID.ToString();//EntityID
                        objEntity = new CRMENTITIES();
                        objEntity.ENTITYID = objMain.RELATEDENTITYID;
                        if (objEntity.LoadByPrimaryKeys())
                            arrResult[10] = objEntity.MODULEID.ToString();//ddlObject
                    }
                    arrResult[12] = LoadShare(objMain.AppID);

                    //if (drw.Length > 0)
                    //{
                    //    if (Convert.ToBoolean(drw[0]["IsShared"]))
                    //    {
                    //        string strDivButtonID = rsdMain.ClientID + "_Form_UpdateButton";
                    //        ScriptManager.RegisterStartupScript(Page, typeof(string), "", "document.getElementById('" + strDivButtonID + "').style.display = 'none';", true);
                    //        Page.ClientScript.RegisterStartupScript(typeof(string), "CloseButtonPanel", "document.getElementById('" + strDivButtonID + "').style.display = 'none';", true);
                    //        isShare = 1;
                    //        pnlProgress.Enabled = false;
                    //    }
                    //    else
                    //    {
                    //        isShare = 0;
                    //        pnlProgress.Enabled = true;
                    //    }
                    //    ScriptManager.RegisterStartupScript(Page, typeof(string), "toggleAll", "toggleAll('" + isShare + "')", true);
                    //    updProgress.Update();
                    //}
                }
            }
            catch
            {
            }
            return arrResult;
        }
        public static void UpdateUserShareData(string strUser, bool IsChecked)
        {
            if (HttpContext.Current.Session["SCH_UserShareData"] != null)
            {
                DataTable dt = (DataTable)HttpContext.Current.Session["SCH_UserShareData"];
                DataRow[] arr = dt.Select("[Tên TK]='" + strUser + "'");
                if (arr.Length > 0)
                    arr[0]["Checked"] = IsChecked;
                HttpContext.Current.Session["SCH_UserShareData"] = dt;
            }
        }
        public void InsertFull(string strSubject, DateTime dtmStart, DateTime dtmEnd, string strRecurrenceRule, int intRecurrenceParentID, bool bolShareAll, string strPlace, int intProcess, int intPriority, int intType, bool bolGroup, string strOwnerUsername, string strObjectName, int intAccountID, string strLstContact, int intEntityID, int intOwner, bool bolExistCRM, string strUserShare, int intMaxUserShare)
        {
            string str = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();

            IDbTransaction objTran = null;
            IData objData = new IData();
            SCHAppointment objMain = new SCHAppointment();
            try
            {
                objData.Connect();
                WebLibs.User objUser = (WebLibs.User)HttpContext.Current.Session["User"];

                objMain.Subject = strSubject;
                //objMain.Start = dtmStart.AddHours(intTimeZone);
                //objMain.End = dtmEnd.AddHours(intTimeZone);
                objMain.Start = dtmStart;
                objMain.End = dtmEnd;
                objMain.RecurrenceRule = strRecurrenceRule;
                objMain.RecurrenceParentID = intRecurrenceParentID;

                objTran = objData.GetConnection().BeginTransaction();
                objData.Transaction = objTran;
                objMain.DataObject = objData;
                objMain.Username = objUser.strUsername;
                objMain.IsShareAll = bolShareAll;
                objMain.UserShare = strUserShare;
                objMain.MaxUsesrShare = intMaxUserShare;
                objMain.Place = strPlace;
                if (intProcess > 0)
                    objMain.ProgressID = intProcess;

                objMain.PriorityID = intPriority;
                objMain.AppType = intType;
                if (bolExistCRM && intEntityID > 0)
                {
                    CRMENTITIES objEntity = new CRMENTITIES();
                    objEntity.DataObject = objData;
                    objEntity.CREATEDUSER = objUser.strUsername;
                    if (!bolGroup)
                    {
                        GlobalFunction objFun = new GlobalFunction();
                        if (strOwnerUsername != "")
                            objEntity.OWNERID = Convert.ToInt32(objFun.GetUserInfo(strOwnerUsername).Rows[0]["UserID"]);
                    }
                    else
                        if (intOwner > 0)
                            objEntity.OWNERID = intOwner;

                    objEntity.MODULEID = CRMENTITIES.Activity;
                    objMain.EntityID = Convert.ToInt32(objEntity.Insert());
                    CRMRELATEDLIST objRELATEDLIST = new CRMRELATEDLIST();
                    objRELATEDLIST.DataObject = objData;
                    if (strObjectName != "")
                    {
                        objMain.RELATEDENTITYID = intAccountID;
                        objMain.RELATEDENTITYNAME = strObjectName;
                    }
                    string[] arrContact = strLstContact.Split(',');
                    for (int i = 0; i < arrContact.Length; i++)
                    {
                        objRELATEDLIST.ENTITYID = objMain.EntityID;
                        objRELATEDLIST.RELATEDENTITYID = Convert.ToInt32(arrContact[i]);
                        objRELATEDLIST.Insert();
                    }
                    objRELATEDLIST.ENTITYID = objMain.EntityID;
                    objRELATEDLIST.RELATEDENTITYID = intEntityID;
                    objRELATEDLIST.Insert();
                }
                int intResult = Convert.ToInt32(objMain.Insert());
                if (intResult > 0)
                {
                    if (!AddGuest(intResult, objData, objMain.IsShareAll, objMain.UserShare, objMain.MaxUsesrShare))
                    {
                        objTran.Rollback();
                        return;
                    }
                }
                objTran.Commit();
            }
            catch
            {
                objTran.Rollback();
            }
            finally
            {
                objData.DeConnect();
            }
            //Cache.Remove("Widget_Scheduler_" + User.strUsername);
        }
        public static void DeleteFull(int intAppID)
        {
            try
            {
                SCHAppointment objMain = new SCHAppointment();
                objMain.AppID = intAppID;
                WebLibs.User objUser = (WebLibs.User)HttpContext.Current.Session["User"];
                if (objMain.LoadByPrimaryKeys())
                    if (objMain.Username != objUser.strUsername)
                    {
                        SCHAppointmentShare objShare = new SCHAppointmentShare();
                        objShare.AppID = intAppID;
                        objShare.Username = objUser.strUsername;
                        objShare.Delete();

                    }
                    else
                        objMain.Delete();
            }
            catch (Exception objEx)
            {
                new SystemMessage("L?i khi xoá s? ki?n!", "", "Controls_MD_Scheduler_Appointment.DoDelete(int intAppID)<br />ERROR: " + objEx.ToString());
            }
        }

        public override void Insert(RadScheduler owner, Appointment appointment)
        {
            //if (!PersistChanges)
            //{
            //    return;
            //}
            //if (appointment.Start > appointment.End)
            //{
            //    return;
            //}
            //if (appointment.Subject.Length < 1)
            //{
            //    return;
            //}

            //IDbTransaction objTran = null;
            //IData objData = new IData();
            //SCHAppointment objMain = new SCHAppointment();
            //try
            //{
            //    objData.Connect();
            //    WebLibs.User objUser = (WebLibs.User)HttpContext.Current.Session["User"];
            //    objTran = objData.GetConnection().BeginTransaction();
            //    objData.Transaction = objTran;
            //    objMain = (SCHAppointment)HttpContext.Current.Session["Appointment_Data"];
            //    objMain.DataObject = objData;

            //    objMain.Subject = appointment.Subject;
            //    objMain.Start = appointment.Start;
            //    objMain.End = appointment.End;
            //    objMain.RecurrenceRule = appointment.RecurrenceRule;
            //    objMain.RecurrenceParentID = Convert.ToInt32(appointment.RecurrenceParentID);

            //    int intResult = Convert.ToInt32(objMain.Insert());
            //    if (intResult > 0)
            //    {
            //        if (!AddGuest(intResult, objData, objMain.IsShareAll, objMain.UserShare, objMain.MaxUsesrShare))
            //        {
            //            objTran.Rollback();
            //            return;
            //        }
            //    }

            //    objTran.Commit();
            //}
            //catch
            //{
            //    objTran.Rollback();
            //}
            //finally
            //{
            //    objData.DeConnect();
            //}
        }
        /// <summary>
        /// Thêm ngu?i chia s? 1 s? ki?n
        /// </summary>
        /// <param name="intAppID"></param>
        private bool AddGuest(int intAppID, IData objData, bool bolShareAll, string strListUserGroup, int intMaxSharedUser)
        {
            SCHAppointmentShare objAppShare = new SCHAppointmentShare();
            objAppShare.DataObject = objData;
            try
            {
                objAppShare.AppID = intAppID;
                objAppShare.DeleteAll();
            }
            catch
            { }
            if (!bolShareAll)
            {
                int iCountUser = 0;
                string[] arrUserGroup = strListUserGroup.Split(',');
                iCountUser = arrUserGroup.Length;

                if (bolShareAll || iCountUser <= intMaxSharedUser)
                {
                    if (arrUserGroup != null)
                    {
                        foreach (string strItem in arrUserGroup)
                        {
                            if (strItem != "")
                            {
                                objAppShare.AppID = intAppID;
                                objAppShare.Username = strItem;
                                if (!objAppShare.LoadByPrimaryKeys())
                                    objAppShare.Insert();
                            }
                        }
                    }
                }
                else
                {
                    return false;
                }
            }
            return true;
        }


        public override void Update(RadScheduler owner, Appointment appointment)
        {
            //if (!PersistChanges)
            //{
            //    return;
            //}
            //if (appointment.Start > appointment.End)
            //{
            //    return;
            //}
            //if (appointment.Subject.Length < 1)
            //{
            //    return;
            //}

            //IDbTransaction objTran = null;
            //IData objData = new IData();
            //SCHAppointment objMain = new SCHAppointment();
            //try
            //{
            //    objData.Connect();
            //    WebLibs.User objUser = (WebLibs.User)HttpContext.Current.Session["User"];
            //    objTran = objData.GetConnection().BeginTransaction();
            //    objData.Transaction = objTran;
            //    objMain = (SCHAppointment)HttpContext.Current.Session["Appointment_Data"];
            //    objMain.DataObject = objData;

            //    objMain.Subject = appointment.Subject;
            //    objMain.Start = appointment.Start;
            //    objMain.End = appointment.End;
            //    objMain.RecurrenceRule = appointment.RecurrenceRule;
            //    objMain.RecurrenceParentID = Convert.ToInt32(appointment.RecurrenceParentID);

            //    int intResult = Convert.ToInt32(objMain.Update());
            //    if (intResult > 0)
            //    {
            //        if (!AddGuest(intResult, objData, objMain.IsShareAll, objMain.UserShare, objMain.MaxUsesrShare))
            //        {
            //            objTran.Rollback();
            //            return;
            //        }
            //    }

            //    objTran.Commit();
            //}
            //catch
            //{
            //    objTran.Rollback();
            //}
            //finally
            //{
            //    objData.DeConnect();
            //}
        }

        public override void Delete(RadScheduler owner, Appointment appointmentToDelete)
        {
            if (!PersistChanges)
            {
                return;
            }
            try
            {
                SCHAppointment objMain = new SCHAppointment();
                objMain.AppID = Convert.ToInt32(appointmentToDelete.ID);
                WebLibs.User objUser = (WebLibs.User)HttpContext.Current.Session["User"];
                if (objMain.LoadByPrimaryKeys())
                    if (objMain.Username != objUser.strUsername)
                    {
                        SCHAppointmentShare objShare = new SCHAppointmentShare();
                        objShare.AppID = Convert.ToInt32(appointmentToDelete.ID);
                        objShare.Username = objUser.strUsername;
                        objShare.Delete();

                    }
                    else
                        objMain.Delete();
            }
            catch (Exception objEx)
            {
                new SystemMessage("L?i khi xoá s? ki?n!", "", "Controls_MD_Scheduler_Appointment.DoDelete(int intAppID)<br />ERROR: " + objEx.ToString());
            }
        }

        public override IEnumerable<ResourceType> GetResourceTypes(RadScheduler owner)
        {
            ResourceType[] resourceTypes = new ResourceType[2];
            resourceTypes[0] = new ResourceType("Teacher", false);
            resourceTypes[1] = new ResourceType("Student", true);

            return resourceTypes;
        }

        public override IEnumerable<Resource> GetResourcesByType(RadScheduler owner, string resourceType)
        {
            switch (resourceType)
            {
                case "Teacher":
                    return Teachers.Values;

                case "Student":
                    return Students.Values;

                default:
                    throw new InvalidOperationException("Unknown resource type: " + resourceType);
            }
        }

        private void LoadResources(Appointment apt)
        {
            using (DbConnection conn = OpenConnection())
            {
                DbCommand cmd = DbFactory.CreateCommand();
                cmd.Connection = conn;

                cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID));
                cmd.CommandText = "SELECT [TeacherID] FROM [DbProvider_Classes] WHERE [ClassID] = @ClassID AND [TeacherID] IS NOT NULL";
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        Resource teacher = Teachers[Convert.ToInt32(reader["TeacherID"])];
                        apt.Resources.Add(teacher);
                    }
                }

                cmd.Parameters.Clear();
                cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID));
                cmd.CommandText = "SELECT [StudentID] FROM [DbProvider_ClassStudents] WHERE [ClassID] = @ClassID";
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Resource student = Students[Convert.ToInt32(reader["StudentID"])];
                        apt.Resources.Add(student);
                    }
                }
            }
        }

        private IEnumerable<Resource> LoadTeachers()
        {
            List<Resource> resources = new List<Resource>();

            //IData objData = new IData();
            //try
            //{
            //    objData.Connect();
            //    objData.CreateNewStoredProcedure("SCH_Appointment_Get");
            //    objData.AddParameter("@strUsername", "administrator");
            //    objData.AddParameter("@intViewOption", 1);
            //    IDataReader reader = objData.ExecStoreToDataReader();

            //    while (reader.Read())
            //    {
            //        Resource res = new Resource();
            //        res.Type = "Teacher";
            //        res.Key = reader["AppID"];
            //        res.Text = Convert.ToString(reader["subject"]);
            //        //res.Attributes["Phone"] = Convert.ToString(reader["Phone"]);
            //        resources.Add(res);
            //    }
            //}
            //catch
            //{
            //}
            //finally
            //{
            //    objData.DeConnect();
            //}

            //using (DbConnection conn = OpenConnection())
            //{
            //    DbCommand cmd = DbFactory.CreateCommand();
            //    cmd.Connection = conn;
            //    cmd.CommandText = "SELECT [TeacherID], [Name], [Phone] FROM [DbProvider_Teachers]";

            //    using (DbDataReader reader = cmd.ExecuteReader())
            //    {
            //        while (reader.Read())
            //        {
            //            Resource res = new Resource();
            //            res.Type = "Teacher";
            //            res.Key = reader["TeacherID"];
            //            res.Text = Convert.ToString(reader["Name"]);
            //            res.Attributes["Phone"] = Convert.ToString(reader["Phone"]);
            //            resources.Add(res);
            //        }
            //    }
            //}

            return resources;
        }

        private IEnumerable<Resource> LoadStudents()
        {
            List<Resource> resources = new List<Resource>();
            //IData objData = new IData();
            //try
            //{
            //    objData.Connect();
            //    objData.CreateNewStoredProcedure("SCH_Appointment_Get");
            //    objData.AddParameter("@strUsername", "administrator");
            //    objData.AddParameter("@intViewOption", 1);
            //    IDataReader reader = objData.ExecStoreToDataReader();

            //    while (reader.Read())
            //    {
            //        Resource res = new Resource();
            //        res.Type = "Teacher";
            //        res.Key = reader["AppID"];
            //        res.Text = Convert.ToString(reader["subject"]);
            //        //res.Attributes["Phone"] = Convert.ToString(reader["Phone"]);
            //        resources.Add(res);
            //    }
            //}
            //catch
            //{
            //}
            //finally
            //{
            //    objData.DeConnect();
            //}
            //using (DbConnection conn = OpenConnection())
            //{
            //    DbCommand cmd = DbFactory.CreateCommand();
            //    cmd.Connection = conn;
            //    cmd.CommandText = "SELECT [StudentID], [Name] FROM [DbProvider_Students]";

            //    using (DbDataReader reader = cmd.ExecuteReader())
            //    {
            //        while (reader.Read())
            //        {
            //            Resource res = new Resource();
            //            res.Type = "Student";
            //            res.Key = reader["StudentID"];
            //            res.Text = Convert.ToString(reader["Name"]);
            //            resources.Add(res);
            //        }
            //    }
            //}

            return resources;
        }

        private void FillClassStudents(Appointment appointment, DbCommand cmd, object classId)
        {
            foreach (Resource student in appointment.Resources.GetResourcesByType("Student"))
            {
                cmd.Parameters.Clear();
                cmd.Parameters.Add(CreateParameter("@ClassID", classId));
                cmd.Parameters.Add(CreateParameter("@StudentID", student.Key));

                cmd.CommandText = "INSERT INTO [DbProvider_ClassStudents] ([ClassID], [StudentID]) VALUES (@ClassID, @StudentID)";
                cmd.ExecuteNonQuery();
            }
        }

        private void ClearClassStudents(object classId, DbCommand cmd)
        {
            cmd.Parameters.Clear();
            cmd.Parameters.Add(CreateParameter("@ClassID", classId));
            cmd.CommandText = "DELETE FROM [DbProvider_ClassStudents] WHERE [ClassID] = @ClassID";
            cmd.ExecuteNonQuery();
        }

        private void PopulateAppointmentParameters(DbCommand cmd, Appointment apt)
        {
            cmd.Parameters.Add(CreateParameter("@Subject", apt.Subject));
            cmd.Parameters.Add(CreateParameter("@Start", apt.Start));
            cmd.Parameters.Add(CreateParameter("@End", apt.End));

            Resource teacher = apt.Resources.GetResourceByType("Teacher");
            object teacherId = null;
            if (teacher != null)
            {
                teacherId = teacher.Key;
            }
            cmd.Parameters.Add(CreateParameter("@TeacherID", teacherId));

            string rrule = null;
            if (apt.RecurrenceRule != string.Empty)
            {
                rrule = apt.RecurrenceRule;
            }
            cmd.Parameters.Add(CreateParameter("@RecurrenceRule", rrule));

            object parentId = null;
            if (apt.RecurrenceParentID != null)
            {
                parentId = apt.RecurrenceParentID;
            }
            cmd.Parameters.Add(CreateParameter("@RecurrenceParentId", parentId));
        }
    }
}
Rully
Top achievements
Rank 2
 answered on 08 Mar 2012
2 answers
112 views
Even after setting ExpandCollapseColumn display to false in my aspx page, there is no effect. is there a way to make the display false in css?
Steve
Top achievements
Rank 1
 answered on 08 Mar 2012
1 answer
65 views
I want to remove >> and << button in a rad calendar..
Shinu
Top achievements
Rank 2
 answered on 08 Mar 2012
2 answers
100 views

Import Problem On Primary key set table ,
Without primary set table data are saved without problem

Thanks,
Mohamed.
mohamed
Top achievements
Rank 1
 answered on 08 Mar 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?