Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    if (Page.Request.QueryString.Count > 0 && Page.Request.QueryString["CID"] != null)
                    {
                        string ID  = Encrypt_Decrypt.Decrypt(Page.Request.QueryString["CID"].ToString(), key);
                        long   CID = 0;
                        if (long.TryParse(ID, out CID) && CID > 0)
                        {
                            int permisionLevel = 0;
                            if (Common.CheckUserInRole(UserID, 5))
                            {
                                permisionLevel = 1; // view all clients from all branches
                            }
                            else
                            {
                                if (Common.CheckUserInRole(UserID, 6))
                                {
                                    permisionLevel = 2; // view all clients from my branche
                                }
                                else
                                {
                                    List <string> groups = new List <string>();
                                    groups.Add("SalesMen");
                                    if (Common.CheckUserInGroups(UserID, groups))
                                    {
                                        permisionLevel = 3; // view my clients
                                    }
                                }
                            }
                            if (permisionLevel > 0)
                            {
                                int            BranchID = Common.GetUserBranchID(UserID);
                                V_Client_Useer client   = new V_Client_Useer();
                                client.Where.ID.Value = CID;
                                if (permisionLevel == 2)
                                {
                                    client.Where.BranchID.Value = BranchID;
                                }
                                if (permisionLevel == 3)
                                {
                                    client.Where.SalesPersonID.Value = UserID;
                                }
                                if (client.Query.Load())
                                {
                                    if (client.DefaultView != null && client.DefaultView.Count > 0)
                                    {
                                        DIV_Content.Visible = true;
                                        Get_Client_Details(client);

                                        if (Common.CheckUserInRole(UserID, 1) && client.BranchID == BranchID)
                                        {
                                            LBTN_Edit.Visible = true;
                                        }
                                        else
                                        {
                                            LBTN_Edit.Visible = false;
                                        }
                                        //GetTextboxes(int.Parse(myID));
                                        LoadClientOrders(client.ID);
                                        LoadClientVolume(client.ID);
                                        LoadClientOpenOffer(client.ID);
                                        if (client.SalesPersonID == UserID && Common.CheckUserInRole(UserID, 7))//AddNewOfferRole
                                        {
                                            btnCreateNewOffer.Visible = true;
                                        }
                                        if (client.s_SupportedByCompany != "")
                                        {
                                            if (client.SupportedByCompany)
                                            {
                                                CHB_SupportedByCompany.Checked = true;
                                                TXT_SupportedBy.Visible        = true;
                                                TXT_SupportedBy.Text           = client.SupportedBy;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        LBL_MSG.Visible = true;
                                        LBL_MSG.Text    = "Please Select a correct Client";
                                    }
                                }
                                else
                                {
                                    LBL_MSG.Visible = true;
                                    LBL_MSG.Text    = "Please Select a correct Client";
                                }
                            }
                            else
                            {
                                LBL_MSG.Visible = true;
                                LBL_MSG.Text    = "You Don't have permission to view this client";
                            }
                        }
                        else
                        {
                            LBL_MSG.Visible = true;
                            LBL_MSG.Text    = "Please Select a correct Client";
                        }
                    }
                    else
                    {
                        LBL_MSG.Visible = true;
                        LBL_MSG.Text    = "Please Select a correct Client";
                    }
                }
                //String myString = HttpContext.Current.Request.Url.PathAndQuery;
                //myString = myString.Substring(myString.IndexOf('?') + 1);

                // String myID = getTaskLinkEnc(myString);
                //  Get_Client_Details(int.Parse(myID));

                //ShowBoxesBasedOnType(myType);
                //GetTextboxes(int.Parse(myID));
            }
            catch (Exception ex)
            {
                LBL_MSG.Visible = true;
                LBL_MSG.Text    = "Page_Load:" + ex.Message;
            }
        }
Пример #2
0
        private void Get_Client_Details(V_Client_Useer client)
        {
            try {
                if (client.Logo != null)
                {
                    var    img          = client.Logo;
                    string base64String = Convert.ToBase64String((byte[])img);
                    IMG_ClientImage.ImageUrl = "data:image/jpg;base64," + base64String;
                }
                else
                {
                    IMG_ClientImage.ImageUrl = "~/UI/Images/male.png";
                }

                myType = client.Type;
                //DataView dt = client.DefaultView;
                LBL_ClientName.Text = client.Name.ToString().Trim();
                if (!string.IsNullOrEmpty(client.s_FirstContractDate))
                {
                    LBL_ClientDuration.Text = client.FirstContractDate.ToString("yyyy");
                }

                this.Page.Title          = client.Name.ToString() + "'s Profile";
                LBL_ClientType.Text      = myType;
                LBL_SalesBersonName.Text = client.FirstName + " " + client.LastName;
                if (client.Photo != null)
                {
                    var    img          = client.Photo;
                    string base64String = Convert.ToBase64String((byte[])img);
                    IMG_SalesManImage.ImageUrl = "data:image/jpg;base64," + base64String;
                }
                else
                {
                    IMG_SalesManImage.ImageUrl = "~/UI/Images/male.png";
                }

                switch (myType)
                {
                case "Small Company (One Branch)":
                {
                    lblCompanyName.Visible = true;
                    tbxCompanyName.Visible = true;
                    tbxCompanyName.Text    = client.Name;

                    lblGroupName.Visible = false;
                    tbxGroupName.Visible = false;

                    lblBranch.Visible = false;
                    tbxBranch.Visible = false;
                }
                break;

                case "Big Company (Multiple Branches)":
                {
                    lblCompanyName.Visible = true;
                    tbxCompanyName.Visible = true;
                    tbxCompanyName.Text    = client.Name;
                    lblBranch.Visible      = true;
                    tbxBranch.Visible      = true;
                    tbxBranch.Text         = client.BranchName;
                    lblGroupName.Visible   = true;
                    tbxGroupName.Visible   = true;
                }
                break;

                case "Group of Companies":
                {
                    lblCompanyName.Visible = true;
                    tbxCompanyName.Visible = true;
                    tbxCompanyName.Text    = client.Name;
                    lblBranch.Visible      = true;
                    tbxBranch.Visible      = true;
                    tbxBranch.Text         = client.BranchName;

                    lblGroupName.Visible = true;
                    tbxGroupName.Visible = true;
                    tbxGroupName.Text    = client.GroupName;
                }
                break;

                case "Individual":
                {
                    lblCompanyName.Visible = true;
                    tbxCompanyName.Visible = true;
                    tbxCompanyName.Text    = client.Name;
                    lblGroupName.Visible   = false;
                    tbxGroupName.Visible   = false;

                    lblBranch.Visible = false;
                    tbxBranch.Visible = false;
                }
                break;
                }

                LoadClientAddresses(client.ID);
                TXT_Email.Text   = client.Email;
                TXT_Website.Text = client.WebSite;
                loadClientPhones(client.ID);
                loadClientMobile(client.ID);
                loadClientFAX(client.ID);
                LoadClientContacts(client.ID);
                LoadClientSpeciality(client.ID);
                if (client.ConsultantType != "")
                {
                    LBL_ConsultanatType.Text = client.ConsultantType;
                }
                if (LBL_ConsultanatType.Text != "N/A")
                {
                    LoadConsaltant(client.ID);
                }
                LBL_FollowUpPeriod.Text = client.s_FollowUpPeriod;
                LoadAttachment(client.ID);
                tbxNote.Text = client.Note;
            }
            catch (Exception ex)
            {
                LBL_MSG.Visible = true;
                LBL_MSG.Text    = "Get_Client:" + ex.Message;
            }
        }