/// <summary>
    /// Get or sets the group of controls for which the editor forces validation when it posts back to the server.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        IList <Organization> banks = null;

        if (IsPostBack == false)
        {
            // Bank Combo Box
            banks = Organization.Find(iSabayaContext, TreeListNode.FindRootByCode(iSabayaContext, "Bank"));
            comboBank.ValueField = "OrganizationID";
            comboBank.TextField  = "Code";
            comboBank.DataSource = banks;
            comboBank.DataBind();
            //
            txtAccountNo.ClientInstanceName   = this.ClientID + txtAccountNo.ClientID;
            comboBank.ClientInstanceName      = this.ClientID + comboBank.ClientID;
            cb1.ClientInstanceName            = this.ClientID + cb1.ClientID;
            lblAccountName.ClientInstanceName = this.ClientID + lblAccountName.ClientID;

            txtAccountNo.ClientSideEvents.ButtonClick = @"function(s,e ){
                var bankID = " + comboBank.ClientInstanceName + @".GetValue();
                var accountID = " + txtAccountNo.ClientInstanceName + @".GetValue();
                " + cb1.ClientInstanceName + @".SendCallback(bankID + ',' + accountID );
            }";

            cb1.ClientSideEvents.CallbackComplete = @"function(s,e ){
                " + lblAccountName.ClientInstanceName + @".SetValue(e.result);
            }";
        }
    }
Exemple #2
0
        private IList <OrgBase> OrganizationList()
        {
            IList <OrgBase> tempOrgList = new List <OrgBase>();
            IList <OrgBase> OrgList     = new List <OrgBase>();

            if (this.selectAll)
            {
                foreach (Organization org in Organization.List(iSabayaContext))
                {
                    if (org.EffectivePeriod.IsEffectiveOn(DateTime.Today))
                    {
                        tempOrgList.Add(org);
                        if (!this.filterOrgUnitOut)
                        {
                            foreach (OrgUnit orgunit in org.OrgUnits)
                            {
                                if (orgunit.EffectivePeriod.IsEffectiveOn(DateTime.Today))
                                {
                                    tempOrgList.Add(orgunit);
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                OrgList = OrgList.Union <OrgBase>(tempOrgList).ToList <OrgBase>();
            }
            if (this.isBank)
            {
                IList <Organization> banks     = Organization.Find(iSabayaContext, TreeListNode.FindRootByCode(iSabayaContext, "Bank"));
                IList <OrgBase>      bankLists = new List <OrgBase>();
                foreach (Organization bank in banks)
                {
                    bankLists.Add(bank);
                    foreach (OrgUnit branch in bank.OrgUnits)
                    {
                        bankLists.Add(branch);
                    }
                }
                OrgList = OrgList.Union <OrgBase>(bankLists).ToList <OrgBase>();
            }

            Session[this.ClientID + "OrganizationLists"] = OrgList;
            return(OrgList);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            txtChequeNo.ClientInstanceName          = this.ClientID + txtChequeNo.ClientID;
            comboBank.ClientInstanceName            = this.ClientID + comboBank.ClientID;
            cb1.ClientInstanceName                  = this.ClientID + cb1.ClientID;
            lblChequeName.ClientInstanceName        = this.ClientID + lblChequeName.ClientID;
            cbpTxtBtnBankAccount.ClientInstanceName = "cbpTxtBtnBankAccount_" + defaultPanelName;
            txtChequeAmount.ClientInstanceName      = this.ClientID + txtChequeAmount.ClientID;
            txtUseAmount.ClientInstanceName         = this.ClientID + txtUseAmount.ClientID;

            txtChequeNo.ClientSideEvents.ButtonClick = @"function(s,e ){
                " + cb1.ClientInstanceName + @".SendCallback();
            }";

            cb1.ClientSideEvents.CallbackComplete = @"function(s,e ){
                var obj1 = eval('('+e.result+')');
                if(obj1.result == true){" + lblChequeName.ClientInstanceName + @".SetValue(obj1.Label);
                " + txtChequeAmount.ClientInstanceName + @".SetValue(obj1.ChequeAmount);}
                else{ alert(obj1.massage); }
            }";
            cbpTxtBtnBankAccount.ClientSideEvents.CallbackComplete = @"function(s,e ){
	            var obj1 = eval('('+e.result+')');
                " + txtChequeNo.ClientInstanceName + @".SetValue(obj1.ChequeNo);
                " + comboBank.ClientInstanceName + @".SetValue(obj1.bankId);
            }";
        }
        IList <Organization> banks = null;

        if (Session[this.GetType().ToString() + "Banks"] == null)
        {
            banks = Organization.Find(iSabayaContext, TreeListNode.FindRootByCode(iSabayaContext, "Bank"));
            Session[this.GetType().ToString() + "Banks"] = banks;
        }
        else
        {
            banks = (IList <Organization>)Session[this.GetType().ToString() + "Banks"];
        }
        comboBank.ValueField = "OrganizationID";
        comboBank.TextField  = "Code";
        comboBank.DataSource = banks;
        comboBank.DataBind();
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            comboBank.ClientInstanceName = CbxClientName;
        }
        IList <Organization> banks = null;

        if (Session[this.GetType().ToString() + "Banks"] == null)
        {
            banks = Organization.Find(iSabayaContext, TreeListNode.FindRootByCode(iSabayaContext, "Bank"));
            Session[this.GetType().ToString() + "Banks"] = banks;
        }
        else
        {
            banks = (IList <Organization>)Session[this.GetType().ToString() + "Banks"];
        }
        comboBank.ValueField = "OrganizationID";
        comboBank.TextField  = "Code";
        comboBank.DataSource = banks;
        comboBank.DataBind();
    }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsCallback)
        {
            if (IsRequiredField)
            {
                textPartyEdit.SetValidation(ValidationGroup, true);
            }
            /*init script*/
            treeList.ClientInstanceName      = this.ClientID + treeList.ClientID;
            textPartyEdit.ClientInstanceName = this.ClientID + textPartyEdit.ClientID;
            popupParty.ClientInstanceName    = this.ClientID + popupParty.ClientID;
            //btnSelect.ClientInstanceName = this.ClientID + btnSelect.ClientID;
            cbpTextPartyEdit.ClientInstanceName = this.ClientID + cbpTextPartyEdit.ClientID;
            labelParty.ClientInstanceName       = this.ClientID + labelParty.ClientID;
            hddOrganization.ClientInstanceName  = this.ClientID + hddOrganization.ClientID;
            string jsScriptTxtPartyEdit = @"var tree = " + treeList.ClientInstanceName + @";
                    var labelFullName = " + labelParty.ClientInstanceName + @";
                    var textInput = " + textPartyEdit.ClientInstanceName + @";
                    if(s.GetText()!= '')
                    {
                        var fullname = '';
                        var isParent = false;
                        for(var i=0; i < tree.cpKeys.length; i++ )
                        {
                            var id = tree.cpKeys[i];
                            var parentCode = tree.cpParentCodes[i];
                            var code = tree.cpCodes[i];
                            " +
                                          (CanSelectUnitOnly ?
                                           @"if(parentCode != '' && (s.GetText() == (parentCode+'-'+code)))
                              {
                                tree.SelectNode(id.toString(), true);
                                fullname = tree.cpFullNames[i];
                                break;
                              }
                              else
                              {
                                tree.SelectNode(id.toString(), false);
                                if(parentCode == '' && (s.GetText() == code))
                                    isParent = true;
                              }
                            "
                            : @"if((s.GetText() == code) || ((parentCode != null)&&(s.GetText() == (parentCode+'-'+code))) )
                              {
                                tree.SelectNode(id.toString(), true);
                                fullname = tree.cpFullNames[i];
                                break;
                              }
                              else
                                tree.SelectNode(id.toString(), false);"
                                          )
                                          + @" }
                            labelFullName.SetText(fullname);
                            if(fullname == '')
                            {
                                if(isParent)
                                    alert('กรุณาเลือกเฉพาะสาขา');
                                else
                                    alert('รหัส '+ s.GetText() +' ไม่มีในระบบ');
                                //textInput.Focus();
                                textInput.SelectAll();
                            }
                    }";
            textPartyEdit.ClientSideEvents.ButtonClick =
                @"function(s, e)
              {
	            var win = "     + popupParty.ClientInstanceName + @".GetWindow(0);
	            "     + popupParty.ClientInstanceName + @".ShowWindow(win);"
                //+ jsScriptTxtPartyEdit
                + "}";
            textPartyEdit.ClientSideEvents.ValueChanged =
                @"function(s, e)
              {"
                + jsScriptTxtPartyEdit + @"
              }";

            String CanSelectUnitOnlyScript = @"function(s, e) {
	                "     + popupParty.ClientInstanceName + @".Hide();
                    var list = new Array();
                    list[0] = 'ID';
                    list[1] = 'FullName';
                    list[2] = 'TypeInString';
                    list[3] = 'Code';
                    list[4] = 'ParentCode';
                    var code;
                    s.GetNodeValues(e.nodeKey, list,
                        function(values) {
                            if(values.length > 0)
                            {"
                                             + labelParty.ClientInstanceName + @".SetText(values[1]);
                                if(values[4] != '' && values[4] != 'null')
                                    code = values[4] + '-' + values[3];
                                else
                                    code = values[3];"
                                             + textPartyEdit.ClientInstanceName + @".SetText(code);
                                if(typeof(oncompleteLoadOrganization) != 'undefined')
                                {
	                                oncompleteLoadOrganization();
                                }
                            }
                        });
                    }";

            String OtherScript = @"function(s, e) {
	                "     + popupParty.ClientInstanceName + @".Hide();
                    var list = new Array();
                    list[0] = 'ID';
                    list[1] = 'FullName';
                    list[2] = 'TypeInString';
                    list[3] = 'Code';
                    list[4] = 'ParentCode';
                    s.GetNodeValues(e.nodeKey, list,
                        function OnGridSelectionComplete(values) {
                            if(values.length > 0)
                            {
                                if(values[2]=='iSabaya.OrgUnit')
                                {"
                                 + labelParty.ClientInstanceName + @".SetText(values[1]);"
                                 + textPartyEdit.ClientInstanceName + @".SetText(values[4] + '-' + values[3]) ;
                                    if(typeof(oncompleteLoadOrganization) != 'undefined')
                                    {
	                                    oncompleteLoadOrganization();
                                    }
                                }
                                else
                                {
                                    alert('กรุณาเลือกเฉพาะสาขา');
                                }
                            }
                        });
                    }";
            if (CanSelectUnitOnly == false)
            {
                treeList.ClientSideEvents.NodeDblClick = CanSelectUnitOnlyScript;
            }
            else
            {
                treeList.ClientSideEvents.NodeDblClick = OtherScript;
            }

            /*init script*/
            if (IsBank == false)
            {
                IList <VOOrgTree> list = new List <VOOrgTree>();

                IList <Organization> organizations = iSabaya.Organization.List(iSabayaContext);
                List <int>           ids           = new List <int>();
                foreach (Organization org in organizations)
                {
                    list.Add(new VOOrgTree(org));
                }
                if (OrganizationOnly == false)
                {
                    #region new codes

                    //add org units to the list
                    foreach (Organization org in organizations)
                    {
                        foreach (OrgUnit orgUnit in org.OrgUnits)
                        {
                            list.Add(new VOOrgTree(orgUnit));
                        }
                    }

                    #endregion new codes

                    #region original codes

                    //ArrayList orgList = ArrayList.Adapter(organizations);
                    //orgList.Sort(new Organization());
                    //IList<OrgUnit> orgUnits = OrgUnit.List(iSabayaContext);
                    //VOOrgTree vo;
                    //if (IsSellingAgent == false)
                    //{
                    //    foreach (OrgUnit org in orgUnits)
                    //    {
                    //        vo = new VOOrgTree(org);
                    //        list.Add(vo);
                    //    }
                    //}
                    //else
                    //{
                    //    foreach (OrgUnit org in orgUnits)
                    //    {
                    //        bool hit = ArrayList.Adapter((IList)organizations).BinarySearch(org.OrganizationParent, new Organization()) > -1;
                    //        if (hit)
                    //        {
                    //            vo = new VOOrgTree(org);
                    //            list.Add(vo);
                    //        }
                    //    }
                    //}

                    #endregion original codes
                }
                treeList.DataSource = list;
                treeList.DataBind();
                treeList.ExpandAll();
                Session[this.ID.ToString() + "ctrls_OrganizationOrgUnitControl_VOOrgTree"] = list;
            }
            else
            {
                //bank
                IList <VOOrgTree> list = new List <VOOrgTree>();

                IList <Organization> banks = Organization.Find(iSabayaContext, TreeListNode.FindRootByCode(iSabayaContext, "Bank"));
                foreach (Organization org in banks)
                {
                    VOOrgTree vo = new VOOrgTree(org);
                    list.Add(vo);
                }
                if (OrganizationOnly == false)
                {
                    #region new codes

                    //add org units to the list
                    foreach (Organization org in banks)
                    {
                        foreach (OrgUnit orgUnit in org.OrgUnits)
                        {
                            VOOrgTree vo = new VOOrgTree(orgUnit);
                            list.Add(vo);
                        }
                    }

                    #endregion new codes

                    #region original codes

                    //IList<OrgUnit> orgUnits = OrgUnit.List(iSabayaContext);
                    //foreach (OrgUnit org in orgUnits)
                    //{
                    //    VOOrgTree vo = new VOOrgTree(org);
                    //    int parentId = org.OrganizationParent.ID;
                    //    bool hit = false;
                    //    for (int i = 0; i < list.Count; i++)
                    //    {
                    //        if (parentId == list[i].ID)
                    //        {
                    //            hit = true;
                    //            break;
                    //        }
                    //    }
                    //    if (hit)
                    //    {
                    //        list.Add(vo);
                    //    }

                    //}

                    #endregion original codes
                }
                treeList.DataSource = list;
                treeList.DataBind();
                treeList.ExpandAll();
                Session[this.ID.ToString() + "ctrls_OrganizationOrgUnitControl_VOOrgTree"] = list;
            }
        }
        else
        {
            if (Session[this.ID.ToString() + "ctrls_OrganizationOrgUnitControl_VOOrgTree"] != null)
            {
                treeList.DataSource = (IList <VOOrgTree>)Session[this.ID.ToString() + "ctrls_OrganizationOrgUnitControl_VOOrgTree"];
                treeList.DataBind();
            }
        }
    }