Ejemplo n.º 1
0
        private void ShowNewMdiChild <TForm>() where TForm : Form, new()
        {
            var childForm = new TForm();

            childForm.MdiParent = this;
            childForm.Show();
        }
Ejemplo n.º 2
0
        public static TForm Create <TForm>() where TForm : TCustomForm, new()
        {
            TForm form = GenericConstructor <TForm> .Default.CreateInstance();

            form.AfterConstruction();
            return(form);
        }
        private static TForm Present <TForm, TView>() where TForm : Form, TView, new()
        {
            var form      = new TForm();
            var presenter = Container.Resolve <IPresenter <TView> >();

            presenter.Initialize(form);
            return(form);
        }
Ejemplo n.º 4
0
        private void ShowEditor <TForm>() where TForm : Form, new()
        {
            var editor = new TForm {
                MdiParent = this
            };

            editor.Show();
        }
Ejemplo n.º 5
0
 public static TForm GetForm <TForm>()
     where TForm : class, new()
 {
     if (_cache.ContainsKey(typeof(TForm)))
     {
         _cache[typeof(TForm)] = new TForm();
     }
     return((TForm)_cache[typeof(TForm)]);
 }
Ejemplo n.º 6
0
        private void ShowChildForm <TForm>() where TForm : Form, new()
        {
            Form childForm = new TForm();

            childForm.MdiParent = this;
            childForm.Name      = "ChildForm - " + DateTime.Now.Millisecond.ToString();
            childForm.Text      = childForm.Name;
            childForm.Show();
        }
Ejemplo n.º 7
0
        private static TForm getForm <TForm>() where TForm : Form, new()
        {
            TForm frm = (TForm)Application.OpenForms.OfType <TForm>().FirstOrDefault();

            if (frm == null)
            {
                frm = new TForm();
            }
            return(frm);
        }
Ejemplo n.º 8
0
 public override void UpdateUi(ScreenActivationContext sac)
 {
     Search = sac.Jq.GetForm("dzebna");
     Items.Clear();
     Items.AddRange(sac.Jq.All("produktebi",
         cqq => new ProductItemViewModel()
             {
                 Name = cqq.GetText("dasakheleba"),
                 Eans = cqq.GetText("eans"),
                 Photo = cqq.GetText("img"),
                 Open = cqq.GetLink("self")
             }));
 }
Ejemplo n.º 9
0
        private void ShowChildForm <TForm>() where TForm : Form, new()
        {
            TForm childForm = new TForm();

            childForm.MdiParent = this;
            childForm.Parent    = splitContainer.Panel2;

            childForm.WindowState = FormWindowState.Normal;
            childForm.Dock        = DockStyle.Fill;
            childForm.Size        = new Size(splitContainer.Width - splitContainer.SplitterDistance, splitContainer.Height);
            childForm.BringToFront();
            childForm.Show();
        }
Ejemplo n.º 10
0
 public override void UpdateUi(ScreenActivationContext sac)
 {
     Search = sac.Jq.GetForm("dzebna");
     Items.Clear();
     Items.AddRange(sac.Jq.All("produktebi",
                               cqq => new ProductItemViewModel()
     {
         Name  = cqq.GetText("dasakheleba"),
         Eans  = cqq.GetText("eans"),
         Photo = cqq.GetText("img"),
         Open  = cqq.GetLink("self")
     }));
 }
Ejemplo n.º 11
0
        public static void ApplyWindow(Window Form, TForm ThemeForm)
        {
            if (!string.IsNullOrWhiteSpace(ThemeForm.Image.Path))
            {
                Form.Background = new ImageBrush(ConvertImage(ThemeForm.Image));
            }
            else
            {
                Form.Background = ConvertColor(ThemeForm.BackColor);
            }

            Form.Topmost = ThemeForm.TopMost;
            Form.Opacity = ThemeForm.Opacity;
        }
Ejemplo n.º 12
0
        public static void Show <TForm>() where TForm : Form, new()
        {
            var form = _activeForms.OfType <TForm>().SingleOrDefault();

            if (form != null)
            {
                form.Activate();
            }
            else
            {
                form = new TForm();
                _activeForms.Add(form);
                form.Show();
            }
        }
Ejemplo n.º 13
0
        void CreateForm <TForm>() where TForm : Form, new()
        {
            var name = typeof(TForm).FullName;
            var cfg  = XConfig.Current;

            if (name != cfg.LastTool)
            {
                cfg.LastTool = name;
                cfg.Save();
            }

            var frm = new TForm();

            CreateForm(frm);
        }
Ejemplo n.º 14
0
        public void ShowOrCreate <TForm>() where TForm : Form, new()
        {
            var instance = Application.OpenForms.OfType <TForm>().FirstOrDefault();

            if (instance == null)
            {
                instance           = new TForm();
                instance.MdiParent = FrmMain.ActiveForm;

                instance.Show();
            }
            else
            {
                instance.Focus();
                instance.WindowState = FormWindowState.Normal;
            }
        }
Ejemplo n.º 15
0
        public void OpenControlledMdiChild <TForm>() where TForm : Form, new()
        {
            bool formFound = false;

            foreach (Form form in this.MdiChildren)
            {
                if (form is TForm)
                {
                    form.BringToFront();
                    formFound = true;
                    break;
                }
            }
            if (!formFound)
            {
                TForm form = new TForm();
                form.MdiParent = this;
                form.Show();
            }
        }
Ejemplo n.º 16
0
        void CreateForm <TForm>() where TForm : Form, new()
        {
            // 倒数第二段
            var ss = typeof(TForm).FullName.Split(".");

            if (ss.Length >= 2)
            {
                var name = ss[ss.Length - 2];
                var cfg  = XConfig.Current;
                if (name != cfg.LastTool)
                {
                    cfg.LastTool = name;
                    cfg.Save();
                }
            }

            var frm = new TForm();

            frm.MdiParent   = this;
            frm.WindowState = FormWindowState.Maximized;
            frm.Show();
        }
Ejemplo n.º 17
0
        protected override void Seed(Tingle_WebForms.Models.FormContext context)
        {
            //Seed Roles
            UserRoles roleUser = new UserRoles {
                RoleName = "User", RoleDescription = "User can submit forms."
            };
            UserRoles roleReportsUser = new UserRoles {
                RoleName = "ReportsUser", RoleDescription = "User can view reports, but not edit them."
            };
            UserRoles roleReportsAdmin = new UserRoles {
                RoleName = "ReportsAdmin", RoleDescription = "User can view and edit reports."
            };
            UserRoles roleSuperUser = new UserRoles {
                RoleName = "SuperUser", RoleDescription = "User has full administrative rights."
            };
            UserRoles roleDeveloper = new UserRoles {
                RoleName = "Developer", RoleDescription = "Developer"
            };

            context.UserRoles.AddOrUpdate(u => u.RoleName, roleUser);
            context.UserRoles.AddOrUpdate(u => u.RoleName, roleReportsUser);
            context.UserRoles.AddOrUpdate(u => u.RoleName, roleReportsAdmin);
            context.UserRoles.AddOrUpdate(u => u.RoleName, roleSuperUser);
            context.UserRoles.AddOrUpdate(u => u.RoleName, roleDeveloper);


            //Seed Forms
            TForm expeditedOrder = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Expedited Order",
                FormNameHtml = "Expedited Order",
                FormUrl      = "ExpeditedOrderForm.aspx",
                Notes        = "Expedited Order Form",
                Status       = 1,
                Timestamp    = DateTime.Now
            };

            TForm priceChangeRequest = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Price Change Request",
                FormNameHtml = "Price Change<br />Request",
                FormUrl      = "PriceChangeRequestForm.aspx",
                Notes        = "Price Change Request Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm orderCancellation = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Order Cancellation",
                FormNameHtml = "Order Cancellation",
                FormUrl      = "OrderCancellationForm.aspx",
                Notes        = "Order Cancellation Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm hotRushForm = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Hot Rush",
                FormNameHtml = "Hot Rush",
                FormUrl      = "HotRushForm.aspx",
                Notes        = "Hot Rush Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm lowInventory = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Low Inventory",
                FormNameHtml = "Low Inventory",
                FormUrl      = "LowInventoryForm.aspx",
                Notes        = "Low Inventory Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm sampleRequest = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Sample Request",
                FormNameHtml = "Sample Request",
                FormUrl      = "SampleRequestForm.aspx",
                Notes        = "Sample Request Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm directOrder = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Direct Order",
                FormNameHtml = "Direct Order",
                FormUrl      = "DirectOrderForm.aspx",
                Notes        = "Direct Order Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm requestForCheck = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Request For Check",
                FormNameHtml = "Request For<br />Check",
                FormUrl      = "RequestForCheckForm.aspx",
                Notes        = "Request For Check Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm mustIncludeForm = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Must Include",
                FormNameHtml = "Must Include",
                FormUrl      = "MustIncludeForm.aspx",
                Notes        = "Must Include Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            TForm cannotWaitForContainerForm = new TForm
            {
                FormCreator  = "Admin",
                FormName     = "Cannot Wait For Container",
                FormNameHtml = "Cannot<br />Wait For<br />Container",
                FormUrl      = "CannotWaitForContainerForm.aspx",
                Notes        = "Cannot Wait For Container Form Notes",
                Status       = 0,
                Timestamp    = DateTime.Now
            };

            if (!context.TForms.Any(x => x.FormName == orderCancellation.FormName))
            {
                context.TForms.Add(orderCancellation);
            }
            if (!context.TForms.Any(x => x.FormName == expeditedOrder.FormName))
            {
                context.TForms.Add(expeditedOrder);
            }
            if (!context.TForms.Any(x => x.FormName == priceChangeRequest.FormName))
            {
                context.TForms.Add(priceChangeRequest);
            }
            if (!context.TForms.Any(x => x.FormName == hotRushForm.FormName))
            {
                context.TForms.Add(hotRushForm);
            }
            if (!context.TForms.Any(x => x.FormName == lowInventory.FormName))
            {
                context.TForms.Add(lowInventory);
            }
            if (!context.TForms.Any(x => x.FormName == sampleRequest.FormName))
            {
                context.TForms.Add(sampleRequest);
            }
            if (!context.TForms.Any(x => x.FormName == directOrder.FormName))
            {
                context.TForms.Add(directOrder);
            }
            if (!context.TForms.Any(x => x.FormName == requestForCheck.FormName))
            {
                context.TForms.Add(requestForCheck);
            }
            if (!context.TForms.Any(x => x.FormName == mustIncludeForm.FormName))
            {
                context.TForms.Add(mustIncludeForm);
            }
            if (!context.TForms.Any(x => x.FormName == cannotWaitForContainerForm.FormName))
            {
                context.TForms.Add(cannotWaitForContainerForm);
            }

            //Seed ExpediteCodes
            ExpediteCode expCode1 = new ExpediteCode {
                Code = "EXP100", Description = "Mill Error", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode2 = new ExpediteCode {
                Code = "EXP200", Description = "Customer Error", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode3 = new ExpediteCode {
                Code = "EXP300", Description = "Tingle Error", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode4 = new ExpediteCode {
                Code = "EXP400", Description = "Install Date", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode5 = new ExpediteCode {
                Code = "EXP500", Description = "Can't wait on production date", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode6 = new ExpediteCode {
                Code = "EXP600", Description = "Search Other Distributors", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode7 = new ExpediteCode {
                Code = "EXP777", Description = "General", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode8 = new ExpediteCode {
                Code = "EXP800", Description = "Direct Order", Status = 1, Timestamp = DateTime.Now
            };
            ExpediteCode expCode9 = new ExpediteCode {
                Code = "EXP911", Description = "Immediate Attn", Status = 1, Timestamp = DateTime.Now
            };

            if (context.ExpediteCodes.Count() < 1)
            {
                if (!context.ExpediteCodes.Any(x => x.Code == expCode1.Code))
                {
                    context.ExpediteCodes.Add(expCode1);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode2.Code))
                {
                    context.ExpediteCodes.Add(expCode2);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode3.Code))
                {
                    context.ExpediteCodes.Add(expCode3);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode4.Code))
                {
                    context.ExpediteCodes.Add(expCode4);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode5.Code))
                {
                    context.ExpediteCodes.Add(expCode5);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode6.Code))
                {
                    context.ExpediteCodes.Add(expCode6);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode7.Code))
                {
                    context.ExpediteCodes.Add(expCode7);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode8.Code))
                {
                    context.ExpediteCodes.Add(expCode8);
                }
                if (!context.ExpediteCodes.Any(x => x.Code == expCode9.Code))
                {
                    context.ExpediteCodes.Add(expCode9);
                }
            }

            //Seed Statuses
            Status status1 = new Status {
                StatusText = "In Progress"
            };
            Status status2 = new Status {
                StatusText = "On Hold"
            };
            Status status3 = new Status {
                StatusText = "Completed"
            };

            if (!context.Statuses.Any())
            {
                if (!context.Statuses.Any(x => x.StatusText == status1.StatusText))
                {
                    context.Statuses.Add(status1);
                }
                if (!context.Statuses.Any(x => x.StatusText == status2.StatusText))
                {
                    context.Statuses.Add(status2);
                }
                if (!context.Statuses.Any(x => x.StatusText == status3.StatusText))
                {
                    context.Statuses.Add(status3);
                }
            }


            //Seed PO Statuses
            PurchaseOrderStatus poStatus1 = new PurchaseOrderStatus {
                Status = "Open", StatusCode = "O"
            };
            PurchaseOrderStatus poStatus2 = new PurchaseOrderStatus {
                Status = "Assigned", StatusCode = "A"
            };
            PurchaseOrderStatus poStatus3 = new PurchaseOrderStatus {
                Status = "Transit", StatusCode = "T"
            };
            PurchaseOrderStatus poStatus4 = new PurchaseOrderStatus {
                Status = "Future", StatusCode = "F"
            };
            PurchaseOrderStatus poStatus5 = new PurchaseOrderStatus {
                Status = "Rejected", StatusCode = "R"
            };
            PurchaseOrderStatus poStatus6 = new PurchaseOrderStatus {
                Status = "Confirmed", StatusCode = "K"
            };


            if (!context.POStatuses.Any())
            {
                context.POStatuses.Add(poStatus1);
                context.POStatuses.Add(poStatus2);
                context.POStatuses.Add(poStatus3);
                context.POStatuses.Add(poStatus4);
                context.POStatuses.Add(poStatus5);
                context.POStatuses.Add(poStatus6);
            }


            //Seed Prioties
            Priority pri1 = new Priority {
                PriorityText = "High"
            };
            Priority pri2 = new Priority {
                PriorityText = "Normal"
            };
            Priority pri3 = new Priority {
                PriorityText = "Low"
            };

            if (!context.Priorities.Any())
            {
                context.Priorities.Add(pri1);
                context.Priorities.Add(pri2);
                context.Priorities.Add(pri3);
            }


            //Seed Price Change Request Products
            PriceChangeRequestProducts prod1 = new PriceChangeRequestProducts {
                ProductText = "Armstrong"
            };
            PriceChangeRequestProducts prod2 = new PriceChangeRequestProducts {
                ProductText = "Other"
            };

            if (!context.PriceChangeRequestProducts.Any())
            {
                context.PriceChangeRequestProducts.Add(prod1);
                context.PriceChangeRequestProducts.Add(prod2);
            }


            //Seed Plants
            Plant plant1 = new Plant {
                PlantText = "Dickson"
            };
            Plant plant2 = new Plant {
                PlantText = "Kankakee"
            };
            Plant plant3 = new Plant {
                PlantText = "Stillwater"
            };
            Plant plant4 = new Plant {
                PlantText = "Lancaster"
            };
            Plant plant5 = new Plant {
                PlantText = "Southgate"
            };
            Plant plant6 = new Plant {
                PlantText = "Other"
            };
            Plant plant7 = new Plant {
                PlantText = "West Plains"
            };
            Plant plant8 = new Plant {
                PlantText = "JacksonTN"
            };
            Plant plant9 = new Plant {
                PlantText = "Jackson"
            };
            Plant plant10 = new Plant {
                PlantText = "Beverly"
            };
            Plant plant11 = new Plant {
                PlantText = "Givens"
            };

            if (!context.Plants.Any())
            {
                context.Plants.Add(plant1);
                context.Plants.Add(plant2);
                context.Plants.Add(plant3);
                context.Plants.Add(plant4);
                context.Plants.Add(plant5);
                context.Plants.Add(plant6);
                context.Plants.Add(plant7);
                context.Plants.Add(plant8);
                context.Plants.Add(plant9);
                context.Plants.Add(plant10);
                context.Plants.Add(plant11);
            }

            //Seed Warehouses
            Warehouse wh1 = new Warehouse {
                WarehouseText = "KAN"
            };
            Warehouse wh2 = new Warehouse {
                WarehouseText = "DEN"
            };
            Warehouse wh3 = new Warehouse {
                WarehouseText = "STL"
            };
            Warehouse wh4 = new Warehouse {
                WarehouseText = "HYD"
            };
            Warehouse wh5 = new Warehouse {
                WarehouseText = "SFG"
            };
            Warehouse wh6 = new Warehouse {
                WarehouseText = "SFH"
            };

            if (!context.Warehouses.Any())
            {
                context.Warehouses.Add(wh1);
                context.Warehouses.Add(wh2);
                context.Warehouses.Add(wh3);
                context.Warehouses.Add(wh4);
                context.Warehouses.Add(wh5);
                context.Warehouses.Add(wh6);
            }


            //Seed User Statuses
            UserStatus us1 = new UserStatus {
                StatusText = "Online"
            };
            UserStatus us2 = new UserStatus {
                StatusText = "Away"
            };
            UserStatus us3 = new UserStatus {
                StatusText = "Busy"
            };

            if (!context.UserStatuses.Any())
            {
                context.UserStatuses.Add(us1);
                context.UserStatuses.Add(us2);
                context.UserStatuses.Add(us3);
            }

            //Seed Vendors
            Vendor v1 = new Vendor {
                Timestamp = DateTime.Now, VendorName = "Armstrong Laminate"
            };
            Vendor v2 = new Vendor {
                Timestamp = DateTime.Now, VendorName = "Armstrong Wood"
            };

            if (!context.Vendors.Any())
            {
                context.Vendors.Add(v1);
                context.Vendors.Add(v2);
            }

            //Seed Inventory Approval Statuses
            InventoryApprovalStatus s1 = new InventoryApprovalStatus {
                StatusDescription = "Pending Approval"
            };
            InventoryApprovalStatus s2 = new InventoryApprovalStatus {
                StatusDescription = "Approved"
            };
            InventoryApprovalStatus s3 = new InventoryApprovalStatus {
                StatusDescription = "Ordered"
            };
            InventoryApprovalStatus s4 = new InventoryApprovalStatus {
                StatusDescription = "Arrived"
            };
            InventoryApprovalStatus s5 = new InventoryApprovalStatus {
                StatusDescription = "Invoiced"
            };
            InventoryApprovalStatus s6 = new InventoryApprovalStatus {
                StatusDescription = "Cancelled"
            };

            if (!context.InventoryApprovalStatuses.Any())
            {
                context.InventoryApprovalStatuses.Add(s1);
                context.InventoryApprovalStatuses.Add(s2);
                context.InventoryApprovalStatuses.Add(s3);
                context.InventoryApprovalStatuses.Add(s4);
                context.InventoryApprovalStatuses.Add(s5);
                context.InventoryApprovalStatuses.Add(s6);
            }



            base.Seed(context);
        }
Ejemplo n.º 18
0
        public static TForm ReadForm <TForm>() where TForm : class
        {
            try {
                ConsoleWriter.RestoreColors();
                PropertyInfo[] formProperties = typeof(TForm).GetProperties();
                if (formProperties.Any(prop => prop.PropertyType != typeof(string) || !prop.CanWrite))
                {
                    throw new InvalidOperationException("All properties should be string and writable.");
                }

                int   maxPropertyLength = formProperties.Max(prop => prop.GetCustomAttribute <FormFieldAttribute>()?.DisplayName?.Length ?? prop.Name.Length);
                int   cursorOffset      = maxPropertyLength + 4;
                TForm formData          = Activator.CreateInstance <TForm>();

                foreach (PropertyInfo property in formProperties)
                {
                    FormFieldAttribute?attribute   = property.GetCustomAttribute <FormFieldAttribute>();
                    string             displayName = attribute?.DisplayName ?? property.Name;
                    bool   nullIfEmpty             = attribute?.NullIfEmpty ?? false;
                    string key  = $"{typeof(TForm).FullName}.{property.Name}";
                    string line = "";
                    if (!_commandHistoryByKey.ContainsKey(key))
                    {
                        _commandHistoryByKey[key]    = new List <string>();
                        _commandHistoryPosByKey[key] = 0;
                    }

                    WriteFieldInput(displayName, line, maxPropertyLength);
                    for (bool breakFor = false; !breakFor;)
                    {
                        ConsoleKeyInfo keyInfo = Console.ReadKey(intercept: true);
                        switch (keyInfo.Key)
                        {
                        case ConsoleKey.Enter:
                            WriteFieldInput(displayName, line, maxPropertyLength, 0);
                            Console.WriteLine();
                            if (line.Length > 0)
                            {
                                if (_commandHistoryPosByKey[key] < _commandHistoryByKey[key].Count - 1)
                                {
                                    _commandHistoryByKey[key].Insert(_commandHistoryPosByKey[key] + 1, line);
                                }
                                else
                                {
                                    _commandHistoryByKey[key].Add(line);
                                }
                                _commandHistoryPosByKey[key]++;
                            }
                            breakFor = true;
                            break;

                        case ConsoleKey.Backspace: {
                            if (line.Length > 0 && Console.CursorLeft > cursorOffset)
                            {
                                if ((keyInfo.Modifiers & ConsoleModifiers.Control) != 0)
                                {
                                    int pos       = Console.CursorLeft - cursorOffset;
                                    int lastIndex = pos > 1 ? line.LastIndexOf(' ', pos - 2) : -1;
                                    if (lastIndex >= 0)
                                    {
                                        int removed = pos - lastIndex;
                                        line = line[..(lastIndex + 1)] + line[pos..];
Ejemplo n.º 19
0
        public void HelloWorld()
        {
            Application = new TApplication(null);
            Application.Initialize();
            Application.Run();

            // Create form
            var lForm = new TForm(null);

            lForm.Width = 800;
            // we can display the form in an existing div element. If Show parameter is nil, a new div is created
            lForm.Show(null);

            var lTopLabel = new TLabel(lForm);

            lTopLabel.Left    = 1;
            lTopLabel.Parent  = lForm;
            lTopLabel.Caption = "Write the item caption on the edit and press Add New button to add to ListBox:";

            var lButton = new TButton(lForm);

            lButton.Left    = 50;
            lButton.Top     = 50;
            lButton.Caption = "Add New";
            lButton.Parent  = lForm;

            var lEdit = new TEdit(lForm);

            lEdit.Left   = 150;
            lEdit.Top    = 50;
            lEdit.Parent = lForm;

            var lListBox = new TListBox(lForm);

            lListBox.Left        = 350;
            lListBox.Top         = 50;
            lListBox.Parent      = lForm;
            lListBox.Width       = 250;
            lListBox.MultiSelect = true;

            lButton.OnClick = (s) => { lListBox.Items.Add(lEdit.Text); };

            var lChangeLabel = new TLabel(lForm);

            lChangeLabel.Top     = 165;
            lChangeLabel.Parent  = lForm;
            lChangeLabel.Caption = "Press button to change label font:";

            var lChangeButton = new TButton(lForm);

            lChangeButton.Left    = 50;
            lChangeButton.Top     = 200;
            lChangeButton.Caption = "Change font";
            lChangeButton.Parent  = lForm;

            var lLabel = new TLabel(lForm);

            lLabel.Left    = 150;
            lLabel.Top     = 200;
            lLabel.Caption = "Sample text!";
            lLabel.Parent  = lForm;

            lChangeButton.OnClick = (s) => { lLabel.Font.Name = "Verdana"; lLabel.Font.Size = 24; };

            var lMemo = new TMemo(lForm);

            lMemo.Left   = 50;
            lMemo.Top    = 300;
            lMemo.Width  = 250;
            lMemo.Height = 150;
            lMemo.Parent = lForm;

            var lMemoButton = new TButton(lForm);

            lMemoButton.Left    = 350;
            lMemoButton.Top     = 325;
            lMemoButton.Caption = "Add text";
            lMemoButton.Parent  = lForm;
            var lList = TStringList.Create();

            lList.Add("one line");
            lList.Add("another one");
            lMemoButton.OnClick = (s) => { lMemo.Lines.AddStrings(lList); };

            var lDisplayButton = new TButton(lForm);

            lDisplayButton.Top     = lMemoButton.Top;
            lDisplayButton.Left    = 450;
            lDisplayButton.Caption = "Show memo text";
            lDisplayButton.Parent  = lForm;
            lDisplayButton.OnClick = (s) => { ShowMessage(lMemo.Lines.Text); };
        }
Ejemplo n.º 20
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    DateTime            tryInstallDate;
                    Nullable <DateTime> installDate = null;
                    DateTime            tryDueDate;
                    Nullable <DateTime> dueDate = null;
                    Int32         formId;
                    int           statusId;
                    int           expediteCodeId;
                    string        emailListString = lblEmailsSentTo.Text.Replace(" ", "");
                    List <string> emailList       = emailListString.Split(',').ToList <string>();

                    System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;
                    UserLogic   uLogic      = new UserLogic();
                    SystemUsers currentUser = uLogic.GetCurrentUser(user);

                    DateTime.TryParse(txtInstallDate.Value, out tryInstallDate);
                    if (txtDueByDate.Value != "")
                    {
                        DateTime.TryParse(txtDueByDate.Value, out tryDueDate);

                        if (tryDueDate.Year > 0001)
                        {
                            dueDate = tryDueDate;
                        }
                    }
                    else
                    {
                        dueDate = null;
                    }

                    if (tryInstallDate.Year > 0001)
                    {
                        installDate = tryInstallDate;
                    }

                    expediteCodeId = Convert.ToInt32(ddlExpediteCode.SelectedValue);
                    statusId       = Convert.ToInt32(ddlStatus.SelectedValue);

                    string accountNumber       = txtAccountNumber.Text;
                    int    accountNumberLength = txtAccountNumber.Text.Length;

                    while (accountNumberLength < 6)
                    {
                        accountNumber = "0" + accountNumber;
                        accountNumberLength++;
                    }

                    using (FormContext ctx = new FormContext())
                    {
                        var   expediteCode    = ctx.ExpediteCodes.FirstOrDefault(c => c.ExpediteCodeID.Equals(expediteCodeId));
                        var   status          = ctx.Statuses.FirstOrDefault(s => s.StatusId.Equals(statusId));
                        Int32 requestedUserId = Convert.ToInt32(ddlRequestedBy.SelectedValue);
                        var   requestedUser   = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == requestedUserId);
                        var   modifiedUser    = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID);

                        Models.ExpeditedOrderForm newForm = new Models.ExpeditedOrderForm
                        {
                            Timestamp           = DateTime.Now,
                            Company             = ddlCompany.SelectedText,
                            Customer            = txtCustomer.Text,
                            AccountNumber       = accountNumber,
                            ExpediteCode        = expediteCode,
                            PurchaseOrderNumber = txtPurchaseOrderNumber.Text,
                            OowOrderNumber      = txtOowOrderNumber.Text,
                            InstallDate         = installDate,
                            SM                    = txtSM.Text,
                            ContactName           = txtContactName.Text,
                            PhoneNumber           = txtPhoneNumber.Text,
                            ShipToName            = txtShipToName.Text,
                            ShipToAddress         = txtShipToAddress.Text,
                            ShipToCity            = txtShipToCity.Text,
                            ShipToState           = txtShipToState.Text,
                            ShipToZip             = txtShipToZip.Text,
                            ShipToPhone           = txtShipToPhone.Text,
                            Status                = ctx.Statuses.FirstOrDefault(s => s.StatusText == ddlStatus.SelectedItem.Text),
                            RequestedUser         = requestedUser,
                            LastModifiedUser      = modifiedUser,
                            SubmittedUser         = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID),
                            DueDate               = dueDate,
                            Priority              = ctx.Priorities.FirstOrDefault(x => x.PriorityText == ddlPriority.SelectedText),
                            LastModifiedTimestamp = DateTime.Now
                        };

                        if (ddlAssignedTo.SelectedIndex != -1)
                        {
                            Int32 assignedUserId = Convert.ToInt32(ddlAssignedTo.SelectedValue);
                            newForm.AssignedUser = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedUserId);
                        }

                        ctx.ExpeditedOrderForms.Add(newForm);
                        ctx.SaveChanges();

                        if (newForm.AssignedUser != null)
                        {
                            Int32 assignedUserId = Convert.ToInt32(ddlAssignedTo.SelectedValue);

                            UserAssignmentAssociation uA = new UserAssignmentAssociation
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                                RelatedFormId = newForm.RecordId,
                                User          = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedUserId)
                            };

                            ctx.UserAssignments.Add(uA);
                        }

                        if (newForm.RequestedUser != null)
                        {
                            UserRequestAssociation uR = new UserRequestAssociation
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                                RelatedFormId = newForm.RecordId,
                                User          = requestedUser
                            };

                            ctx.UserRequests.Add(uR);
                        }

                        ctx.SaveChanges();

                        formId = newForm.RecordId;

                        Comments systemComment = new Comments
                        {
                            Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                            Note          = "Request Created By: " + currentUser.DisplayName,
                            RelatedFormId = formId,
                            SystemComment = true,
                            Timestamp     = DateTime.Now
                        };

                        ctx.Comments.Add(systemComment);

                        Comments systemComment2 = new Comments
                        {
                            Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                            Note          = "Requested By: " + requestedUser.DisplayName,
                            RelatedFormId = formId,
                            SystemComment = true,
                            Timestamp     = DateTime.Now
                        };

                        ctx.Comments.Add(systemComment2);

                        if (ddlAssignedTo.SelectedIndex != -1)
                        {
                            Comments systemComment3 = new Comments
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                                Note          = "Request Assigned To: " + requestedUser.DisplayName,
                                RelatedFormId = formId,
                                SystemComment = true,
                                Timestamp     = DateTime.Now
                            };

                            ctx.Comments.Add(systemComment3);
                        }

                        if (txtComments.Text != "")
                        {
                            Comments firstComment = new Comments
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                                Note          = txtComments.Text,
                                RelatedFormId = formId,
                                SystemComment = false,
                                Timestamp     = DateTime.Now,
                                User          = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID),
                            };

                            ctx.Comments.Add(firstComment);
                            ctx.SaveChanges();
                        }

                        if (ctx.SkuQuantityItems.Any(x => x.TempId == lblRandomIdentifier.Text))
                        {
                            var skus = ctx.SkuQuantityItems.Where(x => x.TempId == lblRandomIdentifier.Text);

                            foreach (var sku in skus)
                            {
                                sku.ExpeditedOrderForm = ctx.ExpeditedOrderForms.FirstOrDefault(x => x.RecordId == formId);
                            }

                            ctx.SaveChanges();
                        }


                        if (lblEmailsSentTo.Text != "")
                        {
                            Comments notifyComment = new Comments
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Expedited Order"),
                                Note          = "Request Notifications Sent To: " + lblEmailsSentTo.Text,
                                RelatedFormId = formId,
                                SystemComment = true,
                                Timestamp     = DateTime.Now
                            };

                            ctx.Comments.Add(notifyComment);

                            ctx.SaveChanges();

                            TForm submittedForm = ctx.TForms.FirstOrDefault(tf => tf.FormName == "Expedited Order");

                            SendEmail     msg      = new SendEmail();
                            StringBuilder bodyHtml = new StringBuilder();

                            bodyHtml.AppendLine("<div style=\"width:50%; text-align:center;\"><img src=\"http://www.wctingle.com/img/Logo.jpg\" /><br /><br />")
                            .Append("A new Expedited Order Request has been submitted.<br /><br />")
                            .AppendLine("<table style=\"border: 4px solid #d0604c;background-color:#FFF;width:100%;margin-lefT:auto; margin-right:auto;\">")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td colspan=\"4\" style=\"text-align: center;vertical-align: middle;font-weight: bold;font-size: 20px;border: 4px solid #d0604c; color:#FFF; background-color:#bc4445;\">Expedited Order Request</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Company:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(ddlCompany.SelectedText).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%; color:#bc4445\"></td>")
                            .AppendLine("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000\"></td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Customer:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtCustomer.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Expedite Code:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(expediteCode.Code).Append(" - ").Append(expediteCode.Description).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Contact Name:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtContactName.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Phone Number:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtPhoneNumber.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr><td colspan=\"4\"><br /></td></tr>");

                            if (ctx.SkuQuantityItems.Any(x => x.ExpeditedOrderForm.RecordId == formId))
                            {
                                bodyHtml.AppendLine("<tr><td colspan=\"4\"><table>");

                                var skus = ctx.SkuQuantityItems.Where(x => x.ExpeditedOrderForm.RecordId == formId);

                                foreach (var sku in skus)
                                {
                                    bodyHtml.AppendLine("<tr>")
                                    .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:20%;color:#bc4445;\">Material SKU#:</td>")
                                    .Append("           <td style=\"text-align:left;font-size:16px;font-weight:bold;width:20%;color:#000;\">").Append(sku.MaterialSku).AppendLine("</td>")
                                    .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:20%;color:#bc4445;\">Quantity Ordered:</td>")
                                    .Append("           <td style=\"text-align:left;font-size:16px;font-weight:bold;width:20%;color:#000;\">").Append(sku.Quantity).AppendLine("</td>")
                                    .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:20%;color:#bc4445;\">Completed:</td>")
                                    .Append("           <td style=\"text-align:left;font-size:16px;font-weight:bold;width:20%;color:#000;\">").Append(sku.Completed.ToString()).AppendLine("</td>")
                                    .AppendLine("    </tr>");
                                }

                                bodyHtml.AppendLine("    </table></td></tr>");
                            }

                            bodyHtml.AppendLine("    <tr><td colspan=\"4\"><br /></td></tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Account Number:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtAccountNumber.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Purchase Order #:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtPurchaseOrderNumber.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">OOW Order Number:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtOowOrderNumber.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">S/M:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtSM.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Install Date:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtInstallDate.Value).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\"></td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\"></td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:left;font-size:16px;font-weight:bold;border: 4px solid #d0604c;color:#FFF; background-color:#bc4445;\" colspan=\"4\">Ship To (If different than default)</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Name:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipToName.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Street Address:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipToAddress.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">City: </td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipToCity.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">State:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipToState.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Zip:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipToZip.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Phone:</td>")
                            .AppendLine("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipToPhone.Text).Append("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("       <td style=\"width:100%;\" colspan=\"4\">")
                            .AppendLine("        <table style=\"border:none; width:100%\">")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td colspan=\"4\">")
                            .AppendLine("                    <span style=\"font-weight:bold; color:#bc4445; text-decoration:underline\">Assignment and Request Details:</span>")
                            .AppendLine("                </td>")
                            .AppendLine("            </tr>")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td style=\"width:20%; text-align:right\"><span class=\"formRedText\">Requested By:</span></td>")
                            .Append("                    <td style=\"width:25%; text-align:left\">").AppendLine(ddlRequestedBy.SelectedItem.Text)
                            .AppendLine("                </td>")
                            .AppendLine("                <td style=\"width:20%; text-align:right\"><span class=\"formRedText\">Assigned To:</span></td>")
                            .Append("                   <td style=\"width:25%; text-align:left\">");

                            if (ddlAssignedTo.SelectedIndex != -1)
                            {
                                bodyHtml.AppendLine(ddlAssignedTo.SelectedItem.Text);
                            }
                            else
                            {
                                bodyHtml.AppendLine("N/A");
                            }

                            bodyHtml.AppendLine("            </td>")
                            .AppendLine("            </tr>")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td style=\"width:18%; text-align:right\"><span class=\"formRedText\">Date Created:</span></td>")
                            .AppendLine("                <td style=\"width:18%; text-align:left\">")
                            .AppendLine(DateTime.Now.ToShortDateString())
                            .AppendLine("                </td>")
                            .AppendLine("                <td style=\"width:18%; text-align:right\"><span class=\"formRedText\">Due By:</span></td>")
                            .Append("                    <td style=\"width:18%; text-align:left\">").Append(txtDueByDate.Value).AppendLine("</td>")
                            .AppendLine("            </tr>")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td style=\"width:10%; text-align:right\"><span class=\"formRedText\">Status:</span></td>")
                            .Append("                    <td style=\"width:10%; text-align:left\">").AppendLine(ddlStatus.SelectedText)
                            .AppendLine("                </td>")
                            .AppendLine("                <td style=\"width:10%; text-align:right\"><span class=\"formRedText\">Priority:</span></td>")
                            .Append("                    <td style=\"width:10%; text-align:left\">").AppendLine(ddlPriority.SelectedText)
                            .AppendLine("                </td>")
                            .AppendLine("            </tr>")
                            .AppendLine("        </table>")
                            .AppendLine("       </td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .Append("       <td style=\"width:100%; text-align:center\" colspan=\"4\">Created By: ").AppendLine(currentUser.DisplayName)
                            .AppendLine("       </td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .Append("           <td style=\"width:100%; text-align:center\" colspan=\"4\"><span style=\"color:#bc4445; font-weight:bold\">Request Notifications Sent To:</span> <br />")
                            .AppendLine(lblEmailsSentTo.Text)
                            .AppendLine("       </td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("           <td style=\"width:100%; text-align:center\" colspan=\"4\"><br /><br /></td>")
                            .AppendLine("    </tr>")
                            .AppendLine("</table><br /><br />");

                            if (cbSendComments.Checked)
                            {
                                bodyHtml.AppendLine("<div style=\"width:80%; color:#bc4445; margin: 0 auto; text-align:center;\">Comments<br /></div>")
                                .AppendLine("<div style=\"width:80%; background-color:#bc4445; margin: 0 auto; text-align: left; padding:3px; color: white; \">")
                                .Append(txtComments.Text).AppendLine("<br /><br />")
                                .AppendLine("<span style=\"padding-right:15px\">").AppendLine(currentUser.DisplayName).AppendLine("</span>")
                                .AppendLine(DateTime.Now.ToString("MMMM dd, yyyy"))
                                .AppendLine("</div>");
                            }

                            bodyHtml.AppendLine("</div><br /><br />");

                            bool result = msg.SendMail("*****@*****.**", emailList, "Expedited Order Request", bodyHtml.ToString(), submittedForm, formId, currentUser);

                            txtAccountNumber.Enabled       = false;
                            txtContactName.Enabled         = false;
                            txtCustomer.Enabled            = false;
                            txtInstallDate.Disabled        = true;
                            txtMaterialSku.Enabled         = false;
                            txtOowOrderNumber.Enabled      = false;
                            txtPhoneNumber.Enabled         = false;
                            txtPurchaseOrderNumber.Enabled = false;
                            txtQuantityOrdered.Enabled     = false;
                            txtShipToAddress.Enabled       = false;
                            txtShipToCity.Enabled          = false;
                            txtShipToName.Enabled          = false;
                            txtShipToState.Enabled         = false;
                            txtShipToZip.Enabled           = false;
                            txtShipToPhone.Enabled         = false;
                            txtSM.Enabled             = false;
                            ddlExpediteCode.Enabled   = false;
                            ddlCompany.Enabled        = false;
                            ddlRequestedBy.Enabled    = false;
                            ddlAssignedTo.Enabled     = false;
                            txtDueByDate.Disabled     = true;
                            ddlStatus.Enabled         = false;
                            ddlPriority.Enabled       = false;
                            cbNotifyStandard.Enabled  = false;
                            cbNotifyRequester.Enabled = false;
                            cbNotifyOther.Enabled     = false;
                            cbNotifyAssignee.Enabled  = false;
                            cbSendComments.Enabled    = false;
                            txtComments.Enabled       = false;
                            btnAddSkuQuantity.Enabled = false;

                            string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                            Response.Redirect(pageUrl + "?FormAction=add&sendEmail=" + result.ToString());
                        }
                        else
                        {
                            string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                            Response.Redirect(pageUrl + "?FormAction=add&sendEmail=NotRequired");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                pnlCompleted.Visible = true;
                pnlForm.Visible      = false;
                lblMessage.Text      = "An error occured during submission of this request.  <br /><br />It is possible that the form was completed before this error occurred, <br />so please contact your System Administrator before re-submitting.";
            }
        }
Ejemplo n.º 21
0
        public void CreateComponents()
        {
            Application = new TApplication(null);
            Application.Initialize();
            Application.Run();

            var el    = Browser.GetElementById("helloWorld");
            var lForm = new TForm(null);

            lForm.Width = 800;
            // el it's a div element in html file, we are using as container for our form
            lForm.Show(el);

            var lFontsPanel = new TPanel(lForm);

            lFontsPanel.Height = 150;
            lFontsPanel.Width  = 800;
            lFontsPanel.Parent = lForm;

            var lFontsCombo = new TComboBox(lForm);

            lFontsCombo.Left  = 30;
            lFontsCombo.Top   = 50;
            lFontsCombo.Width = 130;
            // Add combo inside TPanel
            lFontsCombo.Parent = lFontsPanel;

            lFontsCombo.Items.Add("Arial");
            lFontsCombo.Items.Add("Verdana");
            lFontsCombo.Items.Add("Helvetica");
            lFontsCombo.Items.Add("Times");

            var lFontSize = new TComboBox(lForm);

            lFontSize.Left   = 200;
            lFontSize.Top    = 50;
            lFontSize.Width  = 80;
            lFontSize.Parent = lFontsPanel;
            for (var i = 8; i <= 72; i += 4)
            {
                lFontSize.Items.Add(i.ToString());
            }

            var lLabel = new TLabel(lForm);

            lLabel.Left    = 320;
            lLabel.Top     = 50;
            lLabel.Caption = "Choose font name and size!";
            lLabel.Parent  = lFontsPanel;

            // Assign combo events
            lFontsCombo.OnSelect = (a) => { lLabel.Font.Name = lFontsCombo.Text; };
            lFontSize.OnSelect   = (a) => { lLabel.Font.Size = StrToInt(lFontSize.Text); };

            var lSecondPanel = new TPanel(lForm);

            lSecondPanel.Top    = 220;
            lSecondPanel.Height = 150;
            lSecondPanel.Width  = 800;
            lSecondPanel.Parent = lForm;

            var lCheckBox = new TCheckBox(lForm);

            lCheckBox.Top     = 20;
            lCheckBox.Left    = 30;
            lCheckBox.Caption = "CheckBox control";
            lCheckBox.Parent  = lSecondPanel;

            var lRadioButton = new TRadioButton(lForm);

            lRadioButton.Top     = 80;
            lRadioButton.Left    = 30;
            lRadioButton.Caption = "RadioButton control";
            lRadioButton.Parent  = lSecondPanel;

            var lChangeButton = new TButton(lForm);

            lChangeButton.Left    = 220;
            lChangeButton.Top     = 20;
            lChangeButton.Caption = "Change progress bar mode";
            lChangeButton.Parent  = lSecondPanel;
            lChangeButton.OnClick = @ChangeButtonClick;

            var lIncButton = new TButton(lForm);

            lIncButton.Left    = 220;
            lIncButton.Top     = 80;
            lIncButton.Caption = "Increase progress bar value";
            lIncButton.Parent  = lSecondPanel;
            lIncButton.OnClick = (a) => { fProgress.Position = fProgress.Position + 5; if (fProgress.Position >= fProgress.Max)
                                          {
                                              fProgress.Position = 0;
                                          }
            };

            fProgress        = new TProgressBar(lForm);
            fProgress.Top    = 55;
            fProgress.Left   = 420;
            fProgress.Max    = 100;
            fProgress.Parent = lSecondPanel;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    DateTime            tryDateRequired;
                    Nullable <DateTime> dateRequired = null;
                    Int32               formId;
                    int                 statusId;
                    DateTime            tryDueDate;
                    Nullable <DateTime> dueDate         = null;
                    string              emailListString = lblEmailsSentTo.Text.Replace(" ", "");
                    List <string>       emailList       = emailListString.Split(',').ToList <string>();

                    System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;
                    UserLogic   uLogic      = new UserLogic();
                    SystemUsers currentUser = uLogic.GetCurrentUser(user);

                    DateTime.TryParse(txtDateRequired.Value, out tryDateRequired);

                    if (txtDueByDate.Value != "")
                    {
                        DateTime.TryParse(txtDueByDate.Value, out tryDueDate);

                        if (tryDueDate.Year > 0001)
                        {
                            dueDate = tryDueDate;
                        }
                    }
                    else
                    {
                        dueDate = null;
                    }

                    if (tryDateRequired.Year > 0001)
                    {
                        dateRequired = tryDateRequired;
                    }

                    statusId = Convert.ToInt32(ddlStatus.SelectedValue);

                    using (FormContext ctx = new FormContext())
                    {
                        var   status          = ctx.Statuses.FirstOrDefault(s => s.StatusId.Equals(statusId));
                        Int32 requestedUserId = Convert.ToInt32(ddlRequestedBy.SelectedValue);
                        var   requestedUser   = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == requestedUserId);
                        var   modifiedUser    = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID);

                        Models.OrderCancellationForm newForm = new Models.OrderCancellationForm
                        {
                            Timestamp          = DateTime.Now,
                            Company            = ddlCompany.SelectedValue,
                            OrderNumber        = txtOrderNumber.Text,
                            ArmstrongReference = txtArmstrongReference.Text,
                            Customer           = txtCustomer.Text,
                            PO                    = txtPO.Text,
                            SKU                   = txtSKU.Text,
                            POStatusList          = ddlPOStatus.Text,
                            Line                  = txtLine.Text,
                            LineOfPO              = txtLineOfPO.Text,
                            Size                  = txtSize.Text,
                            DateRequired          = dateRequired.Value,
                            ShipVia               = txtShipVia.Text,
                            Serial                = txtSerial.Text,
                            TruckRoute            = txtTruckRoute.Text,
                            Status                = ctx.Statuses.FirstOrDefault(s => s.StatusText == ddlStatus.SelectedItem.Text),
                            RequestedUser         = requestedUser,
                            LastModifiedUser      = modifiedUser,
                            SubmittedUser         = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID),
                            DueDate               = dueDate,
                            Priority              = ctx.Priorities.FirstOrDefault(x => x.PriorityText == ddlPriority.SelectedText),
                            LastModifiedTimestamp = DateTime.Now
                        };

                        if (ddlAssignedTo.SelectedIndex != -1)
                        {
                            Int32 assignedUserId = Convert.ToInt32(ddlAssignedTo.SelectedValue);
                            newForm.AssignedUser = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedUserId);
                        }

                        ctx.OrderCancellationForms.Add(newForm);
                        ctx.SaveChanges();

                        if (newForm.AssignedUser != null)
                        {
                            Int32 assignedUserId = Convert.ToInt32(ddlAssignedTo.SelectedValue);

                            UserAssignmentAssociation uA = new UserAssignmentAssociation
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                                RelatedFormId = newForm.RecordId,
                                User          = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedUserId)
                            };

                            ctx.UserAssignments.Add(uA);
                        }

                        if (newForm.RequestedUser != null)
                        {
                            UserRequestAssociation uR = new UserRequestAssociation
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                                RelatedFormId = newForm.RecordId,
                                User          = requestedUser
                            };

                            ctx.UserRequests.Add(uR);
                        }

                        ctx.SaveChanges();

                        formId = newForm.RecordId;

                        Comments systemComment = new Comments
                        {
                            Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                            Note          = "Request Created By: " + currentUser.DisplayName,
                            RelatedFormId = formId,
                            SystemComment = true,
                            Timestamp     = DateTime.Now
                        };

                        ctx.Comments.Add(systemComment);

                        Comments systemComment2 = new Comments
                        {
                            Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                            Note          = "Requested By: " + requestedUser.DisplayName,
                            RelatedFormId = formId,
                            SystemComment = true,
                            Timestamp     = DateTime.Now
                        };

                        ctx.Comments.Add(systemComment2);

                        if (ddlAssignedTo.SelectedIndex != -1)
                        {
                            Comments systemComment3 = new Comments
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                                Note          = "Request Assigned To: " + requestedUser.DisplayName,
                                RelatedFormId = formId,
                                SystemComment = true,
                                Timestamp     = DateTime.Now
                            };

                            ctx.Comments.Add(systemComment3);
                        }

                        if (txtComments.Text != "")
                        {
                            Comments firstComment = new Comments
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                                Note          = txtComments.Text,
                                RelatedFormId = formId,
                                SystemComment = false,
                                Timestamp     = DateTime.Now,
                                User          = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID),
                            };

                            ctx.Comments.Add(firstComment);
                            ctx.SaveChanges();
                        }

                        if (lblEmailsSentTo.Text != "")
                        {
                            Comments notifyComment = new Comments
                            {
                                Form          = ctx.TForms.FirstOrDefault(x => x.FormName == "Order Cancellation"),
                                Note          = "Request Notifications Sent To: " + lblEmailsSentTo.Text,
                                RelatedFormId = formId,
                                SystemComment = true,
                                Timestamp     = DateTime.Now
                            };

                            ctx.Comments.Add(notifyComment);

                            ctx.SaveChanges();

                            TForm submittedForm = ctx.TForms.FirstOrDefault(tf => tf.FormName == "Order Cancellation");

                            SendEmail     msg      = new SendEmail();
                            StringBuilder bodyHtml = new StringBuilder();

                            bodyHtml.AppendLine("<div style=\"width:50%; text-align:center;\"><img src=\"http://www.wctingle.com/img/Logo.jpg\" /><br /><br />")
                            .Append("A new Order Cancellation Request has been submitted.<br /><br />")
                            .AppendLine("<table style=\"border: 4px solid #d0604c;background-color:#FFF;width:100%;margin-lefT:auto; margin-right:auto;\">")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td colspan=\"4\" style=\"text-align: center;vertical-align: middle;font-weight: bold;font-size: 20px;border: 4px solid #d0604c; color:#FFF; background-color:#bc4445;\">Order Cancellation Request</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Company:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(ddlCompany.SelectedText).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%; color:#bc4445\"></td>")
                            .AppendLine("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000\"></td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Order #:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtOrderNumber.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Armstrong Reference:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtArmstrongReference.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Customer:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtCustomer.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">PO:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtPO.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">SKU:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtSKU.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Status of PO:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(ddlPOStatus.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Line:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtLine.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Line of PO:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtLineOfPO.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Size:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtSize.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\"></td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:left;font-size:16px;font-weight:bold;border: 4px solid #d0604c;color:#FFF; background-color:#bc4445;\" colspan=\"4\"></td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Date Required:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtDateRequired.Value).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Ship Via:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtShipVia.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Serial:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtSerial.Text).AppendLine("</td>")
                            .AppendLine("        <td style=\"text-align:right;font-size:16px;font-weight:bold;width:25%;color:#bc4445;\">Truck Route:</td>")
                            .Append("        <td style=\"text-align:left;font-size:16px;font-weight:bold;width:25%;color:#000;\">").Append(txtTruckRoute.Text).AppendLine("</td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("       <td style=\"width:100%;\" colspan=\"4\">")
                            .AppendLine("        <table style=\"border:none; width:100%\">")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td colspan=\"4\">")
                            .AppendLine("                    <span style=\"font-weight:bold; color:#bc4445; text-decoration:underline\">Assignment and Request Details:</span>")
                            .AppendLine("                </td>")
                            .AppendLine("            </tr>")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td style=\"width:20%; text-align:right\"><span class=\"formRedText\">Requested By:</span></td>")
                            .Append("                    <td style=\"width:25%; text-align:left\">").AppendLine(ddlRequestedBy.SelectedItem.Text)
                            .AppendLine("                </td>")
                            .AppendLine("                <td style=\"width:20%; text-align:right\"><span class=\"formRedText\">Assigned To:</span></td>")
                            .Append("                   <td style=\"width:25%; text-align:left\">");

                            if (ddlAssignedTo.SelectedIndex != -1)
                            {
                                bodyHtml.AppendLine(ddlAssignedTo.SelectedItem.Text);
                            }
                            else
                            {
                                bodyHtml.AppendLine("N/A");
                            }

                            bodyHtml.AppendLine("            </td>")
                            .AppendLine("            </tr>")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td style=\"width:18%; text-align:right\"><span class=\"formRedText\">Date Created:</span></td>")
                            .AppendLine("                <td style=\"width:18%; text-align:left\">")
                            .AppendLine(DateTime.Now.ToShortDateString())
                            .AppendLine("                </td>")
                            .AppendLine("                <td style=\"width:18%; text-align:right\"><span class=\"formRedText\">Due By:</span></td>")
                            .Append("                    <td style=\"width:18%; text-align:left\">").Append(txtDueByDate.Value).AppendLine("</td>")
                            .AppendLine("            </tr>")
                            .AppendLine("            <tr>")
                            .AppendLine("                <td style=\"width:10%; text-align:right\"><span class=\"formRedText\">Status:</span></td>")
                            .Append("                    <td style=\"width:10%; text-align:left\">").AppendLine(ddlStatus.SelectedText)
                            .AppendLine("                </td>")
                            .AppendLine("                <td style=\"width:10%; text-align:right\"><span class=\"formRedText\">Priority:</span></td>")
                            .Append("                    <td style=\"width:10%; text-align:left\">").AppendLine(ddlPriority.SelectedText)
                            .AppendLine("                </td>")
                            .AppendLine("            </tr>")
                            .AppendLine("        </table>")
                            .AppendLine("       </td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .Append("       <td style=\"width:100%; text-align:center\" colspan=\"4\">Created By: ").AppendLine(currentUser.DisplayName)
                            .AppendLine("       </td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .Append("           <td style=\"width:100%; text-align:center\" colspan=\"4\"><span style=\"color:#bc4445; font-weight:bold\">Request Notifications Sent To:</span> <br />")
                            .AppendLine(lblEmailsSentTo.Text)
                            .AppendLine("       </td>")
                            .AppendLine("    </tr>")
                            .AppendLine("    <tr>")
                            .AppendLine("           <td style=\"width:100%; text-align:center\" colspan=\"4\"><br /><br /></td>")
                            .AppendLine("    </tr>")
                            .AppendLine("</table><br /><br />");

                            if (cbSendComments.Checked)
                            {
                                bodyHtml.AppendLine("<div style=\"width:80%; color:#bc4445; margin: 0 auto; text-align:center;\">Comments<br /></div>")
                                .AppendLine("<div style=\"width:80%; background-color:#bc4445; margin: 0 auto; text-align: left; padding:3px; color: white; \">")
                                .Append(txtComments.Text).AppendLine("<br /><br />")
                                .AppendLine("<span style=\"padding-right:15px\">").AppendLine(currentUser.DisplayName).AppendLine("</span>")
                                .AppendLine(DateTime.Now.ToString("MMMM dd, yyyy"))
                                .AppendLine("</div>");
                            }

                            bodyHtml.AppendLine("</div><br /><br />");

                            bool result = msg.SendMail("*****@*****.**", emailList, "Order Cancellation Request", bodyHtml.ToString(), submittedForm, formId, currentUser);

                            txtOrderNumber.Enabled        = false;
                            txtArmstrongReference.Enabled = false;
                            txtCustomer.Enabled           = false;
                            txtPO.Enabled             = false;
                            txtSKU.Enabled            = false;
                            ddlPOStatus.Enabled       = false;
                            txtLine.Enabled           = false;
                            txtLineOfPO.Enabled       = false;
                            txtSize.Enabled           = false;
                            txtDateRequired.Disabled  = true;
                            txtShipVia.Enabled        = false;
                            txtSerial.Enabled         = false;
                            txtTruckRoute.Enabled     = false;
                            ddlCompany.Enabled        = false;
                            ddlRequestedBy.Enabled    = false;
                            ddlAssignedTo.Enabled     = false;
                            txtDueByDate.Disabled     = true;
                            ddlStatus.Enabled         = false;
                            ddlPriority.Enabled       = false;
                            cbNotifyStandard.Enabled  = false;
                            cbNotifyRequester.Enabled = false;
                            cbNotifyOther.Enabled     = false;
                            cbNotifyAssignee.Enabled  = false;
                            cbSendComments.Enabled    = false;
                            txtComments.Enabled       = false;

                            string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                            Response.Redirect(pageUrl + "?FormAction=add&sendEmail=" + result.ToString(), false);
                        }
                        else
                        {
                            string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                            Response.Redirect(pageUrl + "?FormAction=add&sendEmail=NotRequired");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                pnlCompleted.Visible = true;
                pnlForm.Visible      = false;
                lblMessage.Text      = "An error occured during submission of this request.  <br /><br />It is possible that the form was completed before this error occurred, <br />so please contact your System Administrator before re-submitting.";
            }
        }
Ejemplo n.º 23
0
        private static Figure GenerateFigure()
        {
            Random rnd = new Random();
            Figure figure = null;
            int figureNumber = rnd.Next(1, 8);

            switch (figureNumber)
            {
                case 1:
                    figure = new LForm();
                    return figure;
                case 2:
                    figure = new Line();
                    return figure;
                case 3:
                    figure = new ReversedLForm();
                    return figure;
                case 4:
                    figure = new ReversedZForm();
                    return figure;
                case 5:
                    figure = new Square();
                    return figure;
                case 6:
                    figure = new TForm();
                    return figure;
                case 7:
                    figure = new ZForm();
                    return figure;
                default:
                    return figure;
            }
        }
Ejemplo n.º 24
0
 private static void ShowDialog <TForm>() where TForm : Form, new()
 {
     using (Form form = new TForm())
         form.ShowDialog();
 }
Ejemplo n.º 25
0
        public Boolean SendMail(string from, List <string> emailList, string subject, string bodyHtml, TForm newForm, Int32 formId, SystemUsers sentUser)
        {
            try
            {
                MailMessage completeMessage = new MailMessage();
                completeMessage.From       = new MailAddress(from);
                completeMessage.Subject    = subject;
                completeMessage.Body       = bodyHtml;
                completeMessage.IsBodyHtml = true;

                //SmtpClient client = new SmtpClient("TingleNT30.wctingle.com");
                //client.UseDefaultCredentials = true;
                SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                client.Credentials = new NetworkCredential("*****@*****.**", "ZXCasdQWE123!");
                client.EnableSsl   = true;

                using (FormContext ctx = new FormContext())
                {
                    foreach (string email in emailList)
                    {
                        RequestNotifications newRN = new RequestNotifications
                        {
                            Form            = ctx.TForms.FirstOrDefault(x => x.FormID == newForm.FormID),
                            BodyHtml        = bodyHtml,
                            RequestedFormId = formId,
                            SentBy          = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == sentUser.SystemUserID),
                            Status          = 0,
                            Timestamp       = DateTime.Now,
                            ToEmailAddress  = email
                        };

                        ctx.RequestNotifications.Add(newRN);
                        ctx.SaveChanges();

                        try
                        {
                            completeMessage.To.Clear();
                            completeMessage.To.Add(email);
                            client.Send(completeMessage);

                            newRN.Status = 1;

                            ctx.SaveChanges();
                        }
                        catch (Exception exc)
                        {}
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
                //throw ex;
            }
        }