Exemplo n.º 1
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            BLL.Services Serv = new BLL.Services();

            if (ServiceID>0)
            {
                Serv.LoadByPrimaryKey(ServiceID);
            }
            else
            {
                Serv.AddNew();
            }

            Serv.NameEn = txtServiceName.Text;
            Serv.DescriptionEn = txtServiceDesc.Text;

            if (FileUploadMainImage.HasFile)
            {
                Bitmap UpImg = (Bitmap)Bitmap.FromStream(FileUploadMainImage.PostedFile.InputStream);
                string path = "UploadedFiles/Services/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + FileUploadMainImage.FileName;
                UpImg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png);
                Serv.MainImagePath = path;
            }

            if (FileUploadInternalImage.HasFile)
            {
                Bitmap UpImg = (Bitmap)Bitmap.FromStream(FileUploadInternalImage.PostedFile.InputStream);
                string path = "UploadedFiles/Services/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + FileUploadInternalImage.FileName;
                UpImg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png);
                Serv.InternalImagePath = path;
            }
            Serv.IsActive = chkIsActive.Checked;
            Serv.Save();
            Response.Redirect("services.aspx?sid=" + Serv.s_ServiceID);
        }
Exemplo n.º 2
0
        protected void LinkBtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton btn = (LinkButton)sender;

            BLL.Services obj = new BLL.Services();
            obj.LoadByPrimaryKey(int.Parse(btn.CommandArgument));
            obj.MarkAsDeleted();
            obj.Save();

            LoadAllServices();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadAllServices();

                if (ServiceID>0)
                {
                    placeHolderEditServ.Visible = true;
                    placeHolderGrdView.Visible = false;

                    BLL.Services Serv = new BLL.Services();
                    Serv.LoadByPrimaryKey(ServiceID);
                    txtServiceName.Text = Serv.NameEn;
                    txtServiceDesc.Text = Serv.DescriptionEn;
                    chkIsActive.Checked = Serv.IsActive;
                    if (!string.IsNullOrWhiteSpace(Serv.InternalImagePath))
                    {
                        imgInternalImage.Src = Serv.InternalImagePath;

                    }
                    if (!string.IsNullOrWhiteSpace(Serv.MainImagePath))
                    {
                        imgMainImage.Src = Serv.MainImagePath;

                    }
                    BtnSave.Text = "Update Service";

                    RequiredFieldValidator3.Enabled = false;
                    RequiredFieldValidator4.Enabled = false;
                }
                else if (!string.IsNullOrEmpty(Request.QueryString["NewServ"]))
                {
                    placeHolderEditServ.Visible = true;
                    placeHolderGrdView.Visible = false;
                }
                else
                {
                    placeHolderEditServ.Visible = false;
                    placeHolderGrdView.Visible = true;
                }
            }
        }
Exemplo n.º 4
0
        private void LoadAllServices()
        {
            BLL.Services obj = new BLL.Services();
            obj.LoadAll();

            GrdViewServices.DataSource = obj.DefaultView;
            GrdViewServices.DataBind();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create list of rights
        /// </summary>
        void CreateRights()
        {
            var a = new Services();
            var b = a.GetPlugins();
            var c = Services.GetMenu(b);
            var l1 = typeof(Home.Level1).Name;
            var l2 = typeof(Home.Sytem.Level2).Name;
            var d1 = new Pol_Dictionary();
            var d2 = new Pol_Dictionary();

            foreach (var i in c)
            {
                if (i.Code.Contains(l1)) // level 1
                {
                    d1 = new Pol_Dictionary() { Type = Global.STR_RIGHT, Code = i.Code, Text = i.Text, Order = i.Order, Show = i.Show };
                    d1 = (Pol_Dictionary)Pol_Dictionary.Insert(d1);
                }
                else if (i.Code.Contains(l2)) // level 2
                {
                    d2 = new Pol_Dictionary() { Type = Global.STR_RIGHT, ParentId = d1.Id, Code = i.Code, Text = i.Text, Order = i.Order, Show = i.Show };
                    d2 = (Pol_Dictionary)Pol_Dictionary.Insert(d2);
                }
                else // level 3
                {
                    var d3 = new Pol_Dictionary() { Type = Global.STR_RIGHT, ParentId = d2.Id, Code = i.Code, Text = i.Text, Order = i.Order, Show = i.Show };
                    d3 = (Pol_Dictionary)Pol_Dictionary.Insert(d3);
                }
            }
        }