Example #1
0
        protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            int recSkip = gridMain.CurrentPageIndex * gridMain.PageSize;
            int recTake = gridMain.PageSize;

            try {
                JobTypesController cont = new JobTypesController();
                gridMain.VirtualItemCount = cont.CountJobTypes();
                gridMain.DataSource       = cont.GetJobTypes(recSkip, recTake);
            }
            catch (Exception) { }
        }
Example #2
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item.OwnerTableView.Name == "Master")
     {
         if (e.Item is GridFilteringItem)
         {
             GridFilteringItem filterItem = (GridFilteringItem)e.Item;
             RadDropDownList   clist      = (RadDropDownList)filterItem.FindControl("ddlJobsMainFilter");
             try {
                 JobsMainController jcont = new JobsMainController();
                 clist.DataSource     = jcont.GetJobsMain();
                 clist.DataTextField  = "Name";
                 clist.DataValueField = "ID";
                 clist.DataBind();
                 clist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             }
             catch (Exception) { }
         }
         if (e.Item is GridEditableItem && e.Item.IsInEditMode)
         {
             SalesID = -1;
             Session.Remove("SalesID");
             JobsMainID = -1;
             Session.Remove("JobsMainID");
             JobTypesID = -1;
             Session.Remove("JobTypesID");
             GridEditableItem item        = e.Item as GridEditableItem;
             RadDropDownList  ddlSale     = item.FindControl("ddlSale") as RadDropDownList;
             RadDropDownList  ddlJobsMain = item.FindControl("ddlJobsMain") as RadDropDownList;
             RadDropDownList  ddlJobTypes = item.FindControl("ddlJobTypes") as RadDropDownList;
             try {
                 JobB            currJob = e.Item.DataItem as JobB;
                 SalesController cont    = new SalesController();
                 ddlSale.DataSource     = cont.GetSales();
                 ddlSale.DataTextField  = "Name";
                 ddlSale.DataValueField = "ID";
                 ddlSale.DataBind();
                 ddlSale.Items.Insert(0, new DropDownListItem("Χωρίς Έκπτωση", "0"));
                 JobsMainController cont2 = new JobsMainController();
                 ddlJobsMain.DataSource     = cont2.GetJobsMain();
                 ddlJobsMain.DataTextField  = "Name";
                 ddlJobsMain.DataValueField = "ID";
                 ddlJobsMain.DataBind();
                 JobTypesController cont3 = new JobTypesController();
                 ddlJobTypes.DataSource     = cont3.GetJobTypes();
                 ddlJobTypes.DataTextField  = "Name";
                 ddlJobTypes.DataValueField = "ID";
                 ddlJobTypes.DataBind();
                 if (currJob != null)
                 {
                     if (currJob.SalesID != null)
                     {
                         ddlSale.SelectedIndex = ddlSale.FindItemByValue(currJob.SalesID.ToString()).Index;
                         Session["SalesID"]    = currJob.SalesID;
                     }
                     else
                     {
                         ddlSale.SelectedIndex = 0;
                         Session["SalesID"]    = ddlSale.SelectedItem.Value;
                     }
                     ddlJobsMain.SelectedIndex = ddlJobsMain.FindItemByValue(currJob.JobsMainID.ToString()).Index;
                     Session["JobsMainID"]     = currJob.JobsMainID;
                     ddlJobTypes.SelectedIndex = ddlJobTypes.FindItemByValue(currJob.JobTypesID.ToString()).Index;
                     Session["JobTypesID"]     = currJob.JobTypesID;
                 }
                 else
                 {
                     ddlSale.SelectedIndex     = 0;
                     Session["SalesID"]        = ddlSale.SelectedItem.Value;
                     ddlJobsMain.SelectedIndex = 0;
                     Session["JobsMainID"]     = ddlJobsMain.SelectedItem.Value;
                     ddlJobTypes.SelectedIndex = 0;
                     Session["JobTypesID"]     = ddlJobTypes.SelectedItem.Value;
                 }
             }
             catch (Exception) { }
         }
         else if (e.Item is GridDataItem)
         {
             GridDataItem item    = e.Item as GridDataItem;
             Label        lblST   = item.FindControl("lblSale") as Label;
             JobB         currJob = e.Item.DataItem as JobB;
             if (currJob.SalesID == null)
             {
                 lblST.Text = "Χωρίς Έκπτωση";
             }
             else
             {
                 lblST.Text = currJob.Sale.Name;
             }
         }
     }
 }