コード例 #1
0
        public bool AddArticleNode()
        {
            chkIsLastNode.Enabled = true;
            chkIsLastNode.Checked = false;
            lbltp2TreeCode.Text   = lbltp1TreeCode.Text;
            lbltp2TreeName.Text   = lbltp1TreeName.Text;
            lbltp2NodeCode.Text   = "ANC"
                                    +
                                    CommonModel.SiteCode.ToString()
                                    .Substring(CommonModel.SiteCode.ToString().Length - 3, 3)
                                    +
                                    string.Format("{0}", this.commonManager.GetTranNextNo("AN").ToString().PadLeft(9, '0'));


            SelectedItemNode = this.ItemHierarchyList.Where(a => (a.Nodecode ?? "") == (string)treeView1.SelectedNode.Tag).ToList().FirstOrDefault();

            int maxLevel = articleHierarchyManager.GetMaxTreeLevelCode(lbltp1TreeCode.Text);

            if (!string.IsNullOrEmpty(lbltp1TreeCode.Text))
            {
                string levelCode = "1";
                if (maxLevel == int.Parse(lbltp1NodeLevel.Text))
                {
                    IsLastNode = true;
                    string message = CommonFunc.getResourceString("IH013"); // SpectrumResources.GetString("IH013");
                    MessageBox.Show(message);
                    return(false);
                }
                else
                {
                    if ((bool)SelectedItemNode.ISThisLastNode)
                    {
                        MessageBox.Show(CommonFunc.getResourceString("IH006"));
                        return(false);
                    }
                    else
                    {
                        int levelcode = int.Parse(lbltp1NodeLevel.Text);
                        int newLevel  = levelcode + 1;
                        if (newLevel <= maxLevel)
                        {
                            if (newLevel == maxLevel)
                            {
                                IsLastNode            = true;
                                chkIsLastNode.Checked = true;
                                chkIsLastNode.Enabled = false;
                            }
                            lbltp2LevelCode.Text = newLevel.ToString();
                            lbltp2LevelName.Text = articleHierarchyManager.GetTreeLevelName(lbltp1TreeCode.Text, newLevel);
                        }
                        //else
                        //{
                        //    MessageBox.Show(" Maximum Number of levels defined have been reached. You cannot add another level at this node ");
                        //    return false;
                        //}
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        private void btnDeleteItemHierarchy_Click(object sender, EventArgs e)
        {
            try
            {
                // check how Many active child node if not then can be Delete .
                switch (SaveMode)
                {
                case (int)EnumSave.Tree:
                    int treeChildArticleNoCount = this.articleHierarchyManager.GetTreeChildArticleNoCount(lbltp1TreeCode.Text);
                    if (treeChildArticleNoCount == 0)
                    {
                        if (this.articleHierarchyManager.DeleteTree(lbltp1NodeCode.Text))
                        {
                            MessageBox.Show(CommonFunc.getResourceString("IH002"));
                            BindTree();
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format("{0}{1}", CommonFunc.getResourceString("IH003"), treeChildArticleNoCount));
                    }
                    break;

                case (int)EnumSave.Node:
                    int childArticleNoCount = this.articleHierarchyManager.GetChildArticleNoCount(lbltp1NodeCode.Text);
                    if (childArticleNoCount == 0)
                    {
                        if (this.articleHierarchyManager.DeleteNode(lbltp1NodeCode.Text))
                        {
                            MessageBox.Show(CommonFunc.getResourceString("IH004"));
                            BindTree();
                            HideAllControls();
                        }
                    }
                    else
                    {
                        string message = string.Format(CommonFunc.getResourceString("IH005"), childArticleNoCount);
                        MessageBox.Show(message);
                    }

                    break;
                }
                TreeNode node = treeView1.Nodes[0]; // vipin
                treeView1.SelectedNode = node;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Logger.Log(ex, Logger.LogingLevel.Error);
            }
        }
コード例 #3
0
        private void btnCancelItemHierarchy_Click(object sender, EventArgs e)
        {
            try
            {
                switch (SaveMode)
                {
                case (int)EnumSave.Tree:

                    if (MessageBox.Show(CommonFunc.getResourceString("IH001"), "CNF",
                                        MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                    {
                        return;
                    }
                    HideAllControls();
                    lblItemHierarchyDetails.Visible = true;
                    btnNewTree.Visible = true;
                    break;

                case (int)EnumSave.Node:
                    if (MessageBox.Show(CommonFunc.getResourceString("IH001"), "CNF",
                                        MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                    {
                        return;
                    }
                    lblItemHierarchyDetails2.Visible     = false;
                    tbllayoutPanelItemHierarchy2.Visible = false;
                    panelDbAction.Visible = false;
                    SaveMode = (int)EnumSave.None;
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Logger.Log(ex, Logger.LogingLevel.Error);
            }
        }
コード例 #4
0
        /// <summary>
        ///   Check all form controls have valid data if not display user to message and return fail
        /// </summary>
        /// <returns> form validation sucuss or Fail </returns>
        private bool IsFormvalidate()
        {
            try
            {
                Regex alphaNumericPatt = new Regex("^[A-Za-z0-9- ]+$");
                bool  validateResult   = true;
                bool  isControlFocused = true;

                if ((int)EnumSave.Tree == SaveMode)
                {
                    if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txtFlTreeName, "Tree Name value required"))
                    {
                        this.txtFlTreeName.Focus();
                        validateResult   = false;
                        isControlFocused = false;
                    }
                    // Tree Name Mandatory. Alphanumeric Textbox. Accepts space but no special characters.

                    if (alphaNumericPatt.IsMatch(txtFlTreeName.Text) == false)
                    {
                        validateResult = false;
                        if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txtFlTreeName, " Tree Name is Alphanumeric Textbox. Accepts space but no special characters.", true))
                        {
                            this.txtFlTreeName.Focus();
                        }
                    }
                    else
                    {
                        epArticleHierarchy.SetError(txtFlTreeName, string.Empty);
                        txtFlTreeName.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                    if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txtDefineLevel, "Level value required"))
                    {
                        if (isControlFocused)
                        {
                            this.txtDefineLevel.Focus();
                        }
                        validateResult   = false;
                        isControlFocused = false;
                    }
                    // Check Level Names

                    for (int rowIndex = 1; rowIndex < dgDifineLevel.Rows.Count; rowIndex++)
                    {
                        if (string.IsNullOrEmpty(dgDifineLevel.Rows[rowIndex][1] as string))
                        {
                            MessageBox.Show(CommonFunc.getResourceString("IH012"));
                            this.dgDifineLevel.Focus();
                            validateResult   = false;
                            isControlFocused = false;
                            goto gotLevelResult;
                        }
                        else
                        {
                            if (alphaNumericPatt.IsMatch(dgDifineLevel.Rows[rowIndex][1] as string) == false)
                            {
                                this.dgDifineLevel.Focus();
                                validateResult = false;
                                MessageBox.Show("Tree level at Level Code- " + rowIndex + " is Alphanumeric Textbox. Accepts space but no special characters.");
                                isControlFocused = false;
                                goto gotLevelResult;
                            }
                        }
                    }
                }
                else
                {
                    if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txttp2NodeName, "Set Tree Name"))
                    {
                        this.txttp2NodeName.Focus();
                        validateResult   = false;
                        isControlFocused = false;
                    }
                }
gotLevelResult:
                return(validateResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        private void btnSaveItemHierarchy_Click(object sender, EventArgs e)
        {
            try
            {
                bool IsformValidateSuccess = false;
                switch (SaveMode)
                {
                case (int)EnumSave.Tree:
                    if (IsFormvalidate())
                    {
                        string autoCode = string.Empty;
                        // Save Tree ...
                        ArticleTreeModel             atm  = new ArticleTreeModel();
                        List <ArticleTreeLevelModel> atlm = new List <ArticleTreeLevelModel>();
                        FillTreeModel(ref atm, ref atlm);
                        if ((string.IsNullOrEmpty(_editCode))
                                ? this.articleHierarchyManager.SaveTree(atm, atlm, ref autoCode)
                                : this.articleHierarchyManager.UpdateTree(atm, atlm))
                        {
                            StringBuilder message = new StringBuilder();
                            message.Length = 0;
                            if (!string.IsNullOrEmpty(autoCode))
                            {
                                message.Append("Tree code" + autoCode);
                            }
                            message.Append(CommonFunc.getResourceString("IH007"));
                            MessageBox.Show(message.ToString());
                            ClearTree();
                            BindTree();
                            treeView1.ExpandAll();
                        }
                        IsformValidateSuccess = true;
                    }
                    break;

                case (int)EnumSave.Node:
                    if (IsFormvalidate())
                    {
                        string autoCode = string.Empty;
                        // Save Node ...
                        ArticleNodeModel        anmModel  = new ArticleNodeModel();
                        ArticleTreeNodeMapModel atnmModel = new ArticleTreeNodeMapModel();

                        FillNodeModel(ref anmModel, ref atnmModel);
                        if ((string.IsNullOrEmpty(_editCode))
                                ? this.articleHierarchyManager.SaveNode(anmModel, atnmModel, ref autoCode)
                                : this.articleHierarchyManager.UpdateNode(anmModel))
                        {
                            StringBuilder message = new StringBuilder();
                            message.Length = 0;
                            if (!string.IsNullOrEmpty(autoCode))
                            {
                                message.Append("Node Code " + autoCode + " ");
                            }
                            message.Append(CommonFunc.getResourceString("IH008"));
                            MessageBox.Show(message.ToString());
                            ClearNode();
                            BindTree();
                        }
                        IsformValidateSuccess = true;
                    }
                    break;
                }
                if (IsformValidateSuccess)
                {
                    HideAllControls();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, Logger.LogingLevel.Error);
                MessageBox.Show(ex.Message);
            }
        }