private void LoadLabelInfo()
        {
            SessionStore csSession = SessionManager.GetSession();
            CSLabel      csobj     = csSession.GetCurrentLabel();

            using (var doc = csSession.GetCurrentDocument())
            {
                CodeSoftDTO.LabelInfo dto = new CodeSoftDTO.LabelInfo();
                dto.LabelHeight = doc.CSFormat.LabelHeight.ToString();
                dto.LabelWidth  = doc.CSFormat.LabelWidth.ToString();
                dto.PageHeight  = doc.CSFormat.PageHeight.ToString();
                dto.PageWidth   = doc.CSFormat.PageWidth.ToString();

                dto.Orientation = "Landscape";
                if (doc.CSFormat.Portrait)
                {
                    dto.Orientation = "Portrait";
                }

                JsonSerializerSettings settings = new JsonSerializerSettings();
                settings.ReferenceLoopHandling      = ReferenceLoopHandling.Serialize;
                settings.PreserveReferencesHandling = PreserveReferencesHandling.None;
                string jsonDTO         = JsonConvert.SerializeObject(dto);
                ClientScriptManager cm = ClientScript;
                String JS = "$(document).ready(function(){" +
                            "LabelInfo =" + jsonDTO + ";" +
                            "SetLabelInfo();" +
                            "});";
                cm.RegisterClientScriptBlock(GetType(), "LoadLabelInfo", JS, true);
            }
        }
        private void LoadPreView()
        {
            SessionStore csSession = SessionManager.GetSession();
            CSLabel      csobj     = csSession.GetCurrentLabel();

            if (csobj != null)
            {
                CodeSoftDTO dto = new CodeSoftDTO();
                dto.SessionId = csSession.ID;
                dto.Label     = TemplatesLB.SelectedValue;
                dto.Variables.AddRange(csobj.CSVariables);
                JsonSerializerSettings settings = new JsonSerializerSettings();
                settings.ReferenceLoopHandling      = ReferenceLoopHandling.Serialize;
                settings.PreserveReferencesHandling = PreserveReferencesHandling.None;
                string jsonDTO         = JsonConvert.SerializeObject(dto);
                ClientScriptManager cm = ClientScript;
                String JS = "$(document).ready(function(){" +
                            "CodeSoftDTO=" + jsonDTO + ";" +
                            "varTextBoxID='" + VariableValueTxt.ClientID + "';" +
                            "varListID='" + VariablesLB.ClientID + "';" +
                            "});";
                cm.RegisterClientScriptBlock(GetType(), "LoadPreviewData", JS, true);

                JS = "$(document).ready(function(){" +
                     "GetPreview();" +
                     "});";
                cm.RegisterClientScriptBlock(GetType(), "LoadPreView", JS, true);
            }
        }
        private void SetDirectory()
        {
            try
            {
                SessionStore csSession = SessionManager.GetSession();

                CSDirectory csobj = csSession.GetCurrentDirectory();    // Directories.Where(d => d.Name == name).FirstOrDefault();
                if (csobj != null)
                {
                    //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Existing Current Directory"));
                    if (Directory.Exists(csobj.Path))
                    {
                        //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Found Directory Path"));
                        if (csobj.HasFilesInChild == true && csobj.Labels.Count == 0)
                        {
                            //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Found Labels"));
                            TemplatesLB.Items.Clear();
                            string[] fileEntries = Directory.GetFiles(csobj.Path, "*.lab", SearchOption.AllDirectories);
                            foreach (string fileName in fileEntries)
                            {
                                //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Found File: " + fileName));
                                CSLabel csobjl = new CSLabel();
                                csobjl.Name = fileName.Substring(fileName.LastIndexOf("\\") + 1, fileName.Length - fileName.LastIndexOf("\\") - 1);
                                csobjl.Path = fileName;

                                if (!csobj.Labels.Exists(l => l.Name.ToLower() == csobjl.Name.ToLower()))
                                {
                                    csobj.Labels.Add(csobjl);
                                }

                                if (!SessionManager.Labels.Exists(l => l.Name.ToLower() == csobjl.Name.ToLower()))
                                {
                                    SessionManager.Labels.Add(csobjl);
                                }
                                //SessionManager.Labels.Add(csobjl);
                            }
                        }
                        if (csobj.HasFilesInChild == true)
                        {
                            TemplatesLB.DataSource     = csobj.Labels.OrderBy(o => o.Name);
                            TemplatesLB.DataTextField  = "Name";
                            TemplatesLB.DataValueField = "Path";
                            TemplatesLB.DataBind();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SessionManager.ClearSession();
                log4net.LogManager.GetLogger("ERROR").Error(ex);
                //MessageLbl.Text = "An internal server error has occurred. Check the server logs for details.";
                //Response.Redirect("./");
            }
        }
        private void SaveNoLoading()
        {
            SessionStore   csSession  = SessionManager.GetSession();
            CSLabel        csobj      = csSession.GetCurrentLabel();
            string         values     = VariableValuesHf.Value;
            List <HFValue> valuesJSON = JsonConvert.DeserializeObject <List <HFValue> >(values);

            foreach (HFValue hf in valuesJSON)
            {
                CodeSoftDTO.Variable variable = csobj.CSVariables.Where(v => v.Name == hf.Name).FirstOrDefault();
                if (variable != null)
                {
                    variable.Value = hf.Value;
                }
            }
        }
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                //[{"name":"X_MODS~1","value":"X"},{"name":"X_MODS~2","value":"X"},{"name":"X_MODS~3","value":"X"},{"name":"X_MODS~4","value":"X"}]
                if (VariablesLB.SelectedItem != null)
                {
                    int                  selectedIndex = VariablesLB.SelectedIndex;
                    string               variableName  = VariablesLB.SelectedItem.Text;
                    string               variableValue = VariableValueTxt.Text;
                    SessionStore         csSession     = SessionManager.GetSession();
                    CSLabel              csobj         = csSession.GetCurrentLabel();
                    CodeSoftDTO.Variable variable      = csobj.CSVariables.Where(v => v.Name == variableName).First();
                    variable.Value = variableValue;

                    if (selectedIndex >= VariablesLB.Items.Count - 1)
                    {
                        selectedIndex = -1;
                    }

                    VariablesLB.SelectedIndex = selectedIndex + 1;
                    VariableValueTxt.Text     = "";
                    VariableValueTxt.Focus();
                }
                SaveAndLoad();
            }
            catch (UserError ex)
            {
                MessageLbl.Text = "Save error: " + ex.Message;
            }
            catch (Exception ex)
            {
                SessionManager.ClearSession();
                log4net.LogManager.GetLogger("ERROR").Error(ex);
                Response.Redirect("./");
            }
        }
Example #6
0
        public frmMain(string name)
            : base(name)
        {
            this.Caption = "TELA PRINCIPAL";

              lbl = new CSLabel(this, "lblnomeA", 1, 10);
              lbl.Label = "NOME:     ";
              lbl2 = new CSLabel(this, "lblnome", 1, 11);
              lbl2.Label="ENDERECO:";
              lbl2.Width = 15;
              lbl2.TextAlign = CSTextAlign.RIGHT;
              txt = new CSText(this, "txtNome", lbl.PosX + lbl.Width, 10);
              txt.Filter = new InputFilter();
              txt.TabIndex = 1;
              //txt.Type = CSTextBoxType.NUMERIC;
              //txt.FormatString = "0,00";
              txt.MaxLength = (10);
              //txt.Enabled = false;
              txt.Text = " CASA ";
              txt.TextAlign = CSTextAlign.CENTER;
              txt.Filter = new InputFilter();

              //txt.FormatString = "N2";
              //txt.PasswordChar = "*";

              txt.Width = 20;

              txt.onKeyPress += new onKeyPress(txt_onKeyPress);
              txt2 = new CSText(this, "txtEndereco", lbl2.PosX + lbl2.Width, 11);
              txt2.TabIndex = 2;
              txt2.MaxLength = (50);
              //txt2.InputControlMethod = CSInputControlMethod.READLINE;
             // txt2.Type = CSTextBoxType.DATE;
              //txt.

              //txt2.Enabled = false;

              //button sample
              btn = new CSButton(this, "btnok", 5, 15);
              btn.Label ="COMBO";
              btn.TabIndex = 3;
              btn.Width = 8;
              btn.HotKey = ConsoleKey.F2;
              //btn.Enabled = false;

              //exit sample
              btnSair = new CSButton(this, "btnexit", 15, 15);
              btnSair.Label = "SAIR";
              btnSair.TabIndex = 4;
              btnSair.Width = 8;
              btnSair.HotKey = ConsoleKey.F12;

              // menu
              btnMenu = new CSButton(this, "btnmenu", 25, 15);
              btnMenu.Label = " MENU";
              btnMenu.TabIndex = 5;
              btnMenu.Width = 10;
              btnMenu.HotKey = ConsoleKey.F10;

              //add to the form
              addComponent(lbl);
              addComponent(lbl2);
              addComponent(txt);
              addComponent(txt2);
              addComponent(btn);
              addComponent(btnSair);
              addComponent(btnMenu);

              //events
              btnSair.onClick += new onClick(btnExit_onClick);
              btn.onClick += new onClick(btnOK_onClick);
              btnMenu.onClick += new onClick(btnMenu_onClick);
        }
Example #7
0
        public frmSelecao(string name) : base(name)
        {
            this.Caption = "CADASTRO CLIENTE";

            lbl3       = new CSLabel(this, "lblcliente1", 2, 8);
            lbl3.Label = "CLIENTE:   ";

            cmb           = new CSCombo(this, "cmbcliente", lbl3.Label.Length + 1, 8);
            cmb.Title     = "SELECIONE O CLIENTE";
            cmb.Width     = 20;
            cmb.Height    = 1;
            cmb.TextAlign = CSTextAlign.RIGHT;
            cmb.TabIndex  = 3;

            //dt  = createTable("select codigo, nome as descricao from contatos where codigo in (select fornecedor from pedidoscompra) and id in (select contatoid from contatos_contato) order by nome asc");
            //fill(dt, cmb);
            //for (int i = 1; i < 50; i++)
            //  cmb.addOption("" + i, "" + i);
            cmb.onOptionSelected += new onOptionSelected(cmb_selected);

            cmb1           = new CSCombo(this, "cmbcliente1", lbl3.Label.Length + 1, 9);
            cmb1.Title     = "COMBO 2";
            cmb1.Width     = 20;
            cmb1.Height    = 1;
            cmb1.TextAlign = CSTextAlign.RIGHT;
            cmb1.TabIndex  = cmb.TabIndex + 1;
            //cmb1.addOption("10925", "TUBOS");
            //cmb1.addOption("10926", "RARIDADE");
            //cmb1.addOption("10927", "RARO");
            cmb1.onOptionSelected += new onOptionSelected(cmb1_selected);

            cmb2           = new CSCombo(this, "cmbcliente3", lbl3.Label.Length + 1, 10);
            cmb2.Title     = "COMBO 3";
            cmb2.Width     = 20;
            cmb2.Height    = 1;
            cmb2.TabIndex  = cmb1.TabIndex + 1;
            cmb2.TextAlign = CSTextAlign.RIGHT;
            //cmb2.addOption("10001", "3M");
            //cmb2.addOption("10920", "BOSCH");
            //cmb2.addOption("10921", "ACDELCO");
            cmb2.onOptionSelected += new onOptionSelected(cmb2_selected);


            lbl            = new CSLabel(this, "lblnome", 1, 5);
            lbl.Label      = "NOME: ";
            lbl2           = new CSLabel(this, "lblnomeA", 1, 6);
            lbl2.Label     = "ENDERECO: ";
            txt            = new CSText(this, "txtNome", lbl.PosX + lbl.Label.Length, 5);
            txt.TabIndex   = 1;
            txt.MaxLength  = (50);
            txt2           = new CSText(this, "txtEndereco", lbl2.PosX + lbl2.Label.Length, 6);
            txt2.TabIndex  = 2;
            txt2.MaxLength = (50);

            btn2          = new CSButton(this, "btnok111", 2, 15);
            btn2.Label    = " OK ";
            btn2.TabIndex = cmb2.TabIndex + 1;
            btn2.Width    = 8;

            btn          = new CSButton(this, "btnmensagem", 5, 15);
            btn.Label    = " MSGBOX ";
            btn.TabIndex = btn2.TabIndex + 1;
            btn.Width    = 8;


            btn3          = new CSButton(this, "btnfoco", 15, 15);
            btn3.Label    = " FOCO ";
            btn3.TabIndex = btn.TabIndex + 1;
            btn3.Width    = 8;
            btn3.HotKey   = ConsoleKey.F10;
            btn3.onClick += new onClick(btn3_onClick);


            // add to the form
            addComponent(lbl3);
            addComponent(cmb);
            addComponent(cmb1);
            addComponent(cmb2);
            addComponent(btn2);
            addComponent(btn);
            addComponent(lbl);
            addComponent(lbl2);
            addComponent(txt);
            addComponent(txt2);
            addComponent(btn3);

            // events
            btn2.onClick += new onClick(btnOK2_onClick);
            btn.onClick  += new onClick(btnMsg_onClick);
            //cmb.onOptionSelected += new onOptionSelected(cmb_onOptionSelected);
        }
Example #8
0
        public frmSelecao(string name)
            : base(name)
        {
            this.Caption = "CADASTRO CLIENTE";

              lbl3 = new CSLabel(this, "lblcliente1", 2, 8);
              lbl3.Label = "CLIENTE:   ";

              cmb = new CSCombo(this, "cmbcliente", lbl3.Label.Length + 1, 8);
              cmb.Title = "SELECIONE O CLIENTE";
              cmb.Width = 20;
              cmb.Height = 1;
              cmb.TextAlign = CSTextAlign.RIGHT ;
              cmb.TabIndex = 3;

              //dt  = createTable("select codigo, nome as descricao from contatos where codigo in (select fornecedor from pedidoscompra) and id in (select contatoid from contatos_contato) order by nome asc");
              //fill(dt, cmb);
              //for (int i = 1; i < 50; i++)
              //  cmb.addOption("" + i, "" + i);
              cmb.onOptionSelected += new onOptionSelected(cmb_selected);

              cmb1 = new CSCombo(this, "cmbcliente1", lbl3.Label.Length + 1, 9);
              cmb1.Title = "COMBO 2";
              cmb1.Width = 20;
              cmb1.Height = 1;
              cmb1.TextAlign = CSTextAlign.RIGHT;
              cmb1.TabIndex = cmb.TabIndex + 1;
              //cmb1.addOption("10925", "TUBOS");
              //cmb1.addOption("10926", "RARIDADE");
              //cmb1.addOption("10927", "RARO");
              cmb1.onOptionSelected += new onOptionSelected(cmb1_selected);

              cmb2 = new CSCombo(this, "cmbcliente3", lbl3.Label.Length + 1, 10);
              cmb2.Title = "COMBO 3";
              cmb2.Width = 20;
              cmb2.Height = 1;
              cmb2.TabIndex = cmb1.TabIndex + 1;
              cmb2.TextAlign = CSTextAlign.RIGHT;
              //cmb2.addOption("10001", "3M");
              //cmb2.addOption("10920", "BOSCH");
              //cmb2.addOption("10921", "ACDELCO");
              cmb2.onOptionSelected += new onOptionSelected(cmb2_selected);

              lbl = new CSLabel(this, "lblnome", 1, 5);
              lbl.Label = "NOME: ";
              lbl2 = new CSLabel(this, "lblnomeA", 1, 6);
              lbl2.Label = "ENDERECO: ";
              txt = new CSText(this, "txtNome", lbl.PosX + lbl.Label.Length, 5);
              txt.TabIndex = 1;
              txt.MaxLength = (50);
              txt2 = new CSText(this, "txtEndereco", lbl2.PosX + lbl2.Label.Length, 6);
              txt2.TabIndex = 2;
              txt2.MaxLength = (50);

              btn2 = new CSButton(this, "btnok111", 2, 15);
              btn2.Label = " OK ";
              btn2.TabIndex = cmb2.TabIndex+1;
              btn2.Width = 8;

              btn = new CSButton(this, "btnmensagem", 5, 15);
              btn.Label = " MSGBOX ";
              btn.TabIndex = btn2.TabIndex+1;
              btn.Width = 8;

              btn3 = new CSButton(this, "btnfoco", 15, 15);
              btn3.Label = " FOCO ";
              btn3.TabIndex = btn.TabIndex + 1;
              btn3.Width = 8;
              btn3.HotKey = ConsoleKey.F10;
              btn3.onClick += new onClick(btn3_onClick);

              // add to the form
              addComponent(lbl3);
              addComponent(cmb);
              addComponent(cmb1);
              addComponent(cmb2);
              addComponent(btn2);
              addComponent(btn);
              addComponent(lbl);
              addComponent(lbl2);
              addComponent(txt);
              addComponent(txt2);
              addComponent(btn3);

              // events
              btn2.onClick += new onClick(btnOK2_onClick);
              btn.onClick += new onClick(btnMsg_onClick );
              //cmb.onOptionSelected += new onOptionSelected(cmb_onOptionSelected);
        }
Example #9
0
        public frmMain(string name) : base(name)
        {
            this.Caption = "TELA PRINCIPAL";

            lbl            = new CSLabel(this, "lblnomeA", 1, 10);
            lbl.Label      = "NOME:     ";
            lbl2           = new CSLabel(this, "lblnome", 1, 11);
            lbl2.Label     = "ENDERECO:";
            lbl2.Width     = 15;
            lbl2.TextAlign = CSTextAlign.RIGHT;
            txt            = new CSText(this, "txtNome", lbl.PosX + lbl.Width, 10);
            txt.Filter     = new InputFilter();
            txt.TabIndex   = 1;
            //txt.Type = CSTextBoxType.NUMERIC;
            //txt.FormatString = "0,00";
            txt.MaxLength = (10);
            //txt.Enabled = false;
            txt.Text      = " CASA ";
            txt.TextAlign = CSTextAlign.CENTER;
            txt.Filter    = new InputFilter();

            //txt.FormatString = "N2";
            //txt.PasswordChar = "*";

            txt.Width = 20;

            txt.onKeyPress += new onKeyPress(txt_onKeyPress);
            txt2            = new CSText(this, "txtEndereco", lbl2.PosX + lbl2.Width, 11);
            txt2.TabIndex   = 2;
            txt2.MaxLength  = (50);
            //txt2.InputControlMethod = CSInputControlMethod.READLINE;
            // txt2.Type = CSTextBoxType.DATE;
            //txt.

            //txt2.Enabled = false;

            //button sample
            btn          = new CSButton(this, "btnok", 5, 15);
            btn.Label    = "COMBO";
            btn.TabIndex = 3;
            btn.Width    = 8;
            btn.HotKey   = ConsoleKey.F2;
            //btn.Enabled = false;

            //exit sample
            btnSair          = new CSButton(this, "btnexit", 15, 15);
            btnSair.Label    = "SAIR";
            btnSair.TabIndex = 4;
            btnSair.Width    = 8;
            btnSair.HotKey   = ConsoleKey.F12;

            // menu
            btnMenu          = new CSButton(this, "btnmenu", 25, 15);
            btnMenu.Label    = " MENU";
            btnMenu.TabIndex = 5;
            btnMenu.Width    = 10;
            btnMenu.HotKey   = ConsoleKey.F10;

            //add to the form
            addComponent(lbl);
            addComponent(lbl2);
            addComponent(txt);
            addComponent(txt2);
            addComponent(btn);
            addComponent(btnSair);
            addComponent(btnMenu);

            //events
            btnSair.onClick += new onClick(btnExit_onClick);
            btn.onClick     += new onClick(btnOK_onClick);
            btnMenu.onClick += new onClick(btnMenu_onClick);
        }
        private void LoadVariables()
        {
            VariablesLB.Items.Clear();
            SessionStore csSession = SessionManager.GetSession();
            CSLabel      csobj     = csSession.GetCurrentLabel();

            if (csobj != null)
            {
                if (csobj.CSVariables.Count == 0)
                {
                    using (var doc = csSession.GetCurrentDocument())
                    {
                        foreach (CSVariable aVariable in doc.CSVariables.OrderBy(p => p.Name))
                        {
                            //CSVariable aVariable = doc.CSVariables[i];
                            CodeSoftDTO.Variable csVar = new CodeSoftDTO.Variable();

                            csVar.Name           = aVariable.Name;
                            csVar.Value          = ""; //aVariable.Value;
                            csVar.ArrayBaseShift = 0;
                            csVar.IsHidden       = !aVariable.IsUserInput;

                            if (aVariable.Name.ToLower().Contains("x_"))
                            {
                                var    regex  = new Regex("[^a-zA-Z0-9]");
                                var    regex2 = new Regex(@"\d+");
                                string root   = aVariable.Name.Replace("X_", "").Replace("x_", "");
                                string index  = regex2.Match(root).Value;
                                root = root.Remove(regex.Match(root).Index);
                                if (!root.ToLower().Contains("mod"))
                                {
                                    csVar.ArrayBaseShift = -1;
                                }
                                csVar.ArrayIndex = Int32.Parse(index);
                                csVar.GroupName  = root;
                                csVar.IsXBox     = true;
                                csVar.IsHidden   = true;
                            }

                            csobj.AddVariable(csVar);
                        }

                        /*CodeSoftDTO.Variable csVarQty = new CodeSoftDTO.Variable();
                         * csVarQty.Name = "LABEL_QUANTITY";
                         * csVarQty.Value = "1";
                         * csVarQty.ArrayBaseShift = 0;
                         * csobj.AddVariable(csVarQty);*/
                    }
                }


                List <HFValue> HFValues = new List <HFValue>();
                foreach (CodeSoftDTO.Variable v in csobj.CSVariables.Where(v => string.IsNullOrEmpty(v.Name) == false))
                {
                    ListItem item = new ListItem(v.Name);
                    item.Attributes.Add("tag", v.Value);

                    if (v.IsXBox)
                    {
                        HFValues.Add(new HFValue()
                        {
                            Name = v.Name, Value = v.Value
                        });
                    }

                    /*if (v.IsHidden)
                     * {
                     *  item.Attributes.Add("style", "display:none;");
                     *  item.Attributes.Add("disabled", "true");
                     * }*/
                    if (!v.IsHidden)
                    {
                        VariablesLB.Items.Add(item);
                    }
                }

                VariableValuesHf.Value = JsonConvert.SerializeObject(HFValues);
                //load the groups in the browser.
                string jscript = "";
                var    groups  = csobj.CSVariables.Where(l => l.GroupName != null).GroupBy(g => g.GroupName);
                foreach (var group in groups)
                {
                    CodeSoftDTO.VariableGroup vgroup = new CodeSoftDTO.VariableGroup();
                    vgroup.Name = group.Key;
                    jscript    += "groups.push('" + vgroup.Name + "');";
                    vgroup.Variables.AddRange(csobj.CSVariables.Where(v => v.GroupName == vgroup.Name).Cast <CodeSoftDTO.Variable>());
                    foreach (CodeSoftDTO.Variable v in vgroup.Variables.OrderBy(o => o.ArrayIndex))
                    {
                        jscript += "groupItems.push({ group: \"" + vgroup.Name + "\", item: \"<div class='x_item' ><label for='" + v.Name + "' class='x_item_label' >" + (v.ArrayIndex + v.ArrayBaseShift) + "</label><input type='checkbox' id='" + v.Name + "' class='x_item_chk' /></div>\" });";
                    }
                }
                ClientScriptManager cm = ClientScript;
                cm.RegisterClientScriptBlock(GetType(), "LoadXGroupData", jscript, true);

                if (HFValues.Count > 0)
                {
                    cm       = ClientScript;
                    jscript  = "$(document).ready(function () {";
                    jscript += "$('#x_dialogIcon').show();";
                    jscript += "});";
                    cm.RegisterClientScriptBlock(GetType(), "HideXDialog", jscript, true);
                }
            }
        }