6 Replies Latest reply on Aug 12, 2011 5:51 AM by Venkatesan Balasubramanian

    how to avoid  save same employee name under same company name

    Venkatesan Balasubramanian Level 1

      hi,

       

      i am doing flex4 web application with mxml tags,

       

      i am having one text box and one datagrid and one save button. text box having one company name, data grid having employee names.

       

      when i click save button which is placed in outside the datagrid it will save all the details.

       

       

      Now my requirement is text box having the same company name and when i enter same employee name in datagrid and click save button means it wont

      allow to save that record, and through msg box with some alerts.

       

       

      How to do this,

       

      Any suggession or snippet code are welcome

       

      Thanks ,

       

      B.venkatesan

        • 1. Re: how to avoid  save same employee name under same company name
          Kumar Pratik

          Dint understand your question.. An example could help

          • 2. Re: how to avoid  save same employee name under same company name
            Venkatesan Balasubramanian Level 1

            hi,

             

            i am doing flex4 web application with mxml tags,

             

            i  am having one text box and one datagrid and one save button. text box  having one company name, data grid having employee names.

             

            when i click save button which is placed in outside the datagrid it will save all the details in cloud DTO.

             

             

            Now  my requirement is text box having the same company name and when i  enter same employee name in datagrid and click save button means it wont

            allow to save that record, and through msg box with some alerts.

             

            this is my code:

             

            private function saveRecord():void
                    {
                        refreshRecords();
                        model.employeeDetailsReq=new EMPLOYEEDETAILS_DTO();
                        {
                            var lengthindex:uint=model.employeeDetailsReqRecordsList.length;
                            var i:int;
                            for (i = 0; i < lengthindex; i++)
                            {
                            if((model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employee name==customerdet.selectedItem.employeename)&&
                                (model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employeeNumber==customerdet.s electedItem.employeeID)){
                                Alert.show("you cannot Add Same CustomerName and Invoiceno again");

            (when this line come the error through like this: Index '8' specified is out of bounds.
                           
                            }

            else

            {

             

            var dp:Object=employeedet.dataProvider;             

            var cursor:IViewCursor=dp.createCursor();
            var employeename:String = employeename.text;


                     model.employeeDetailsReq.employename = employeename;

            model.employeeDetailsReq.employeeNumber=cursor.current.employeeID;

            var sendRecordToLocID:QuickBaseEventStoreRecord = new
                                QuickBaseEventStoreRecord(model.employeeDetailsReq, new
                                    KingussieEventCallBack(refreshList))
                            sendRecordToLocID.dispatch();

            }

             

            <mx:Button id="btnAdd" x="33" y="419" enabled="false" label="Add" width="65" fontFamily="Georgia" fontSize="12" click="saveRecord()"/>


            employeename and employeeID are datafields of datagrid. datagrid id=customerdet

             

            employeeDetailsReqRecordsList---recordlist of save records

             

             

            please help .

            any suggession or snippet code welcome

             

             

            B.venkatesan

            • 3. Re: how to avoid  save same employee name under same company name
              miguel8312 Level 3

              if I understand correctly you would like to not save a record that has already been saved. if that

              s the case then how are you saving the records on the click event of the grid. if you are using listevent then you can

              grab the datagrid column values add to an array or make a service call to server and compare the value to see if its already there if its there then throw and alert box up if its not then save it.

              Let me know if this answers your question.

              Miguel

              • 4. Re: how to avoid  save same employee name under same company name
                Venkatesan Balasubramanian Level 1

                hi miguel8312,

                 

                you said"if I understand correctly you would like to not save a record that has already been saved. if that

                s the case then how are you saving the records on the click event of the grid"

                 

                till tat ur answer is correct after that , i am not using any server while creating a flex4 web application.so i cant make any request to the severr.i am using

                 

                cloud to store my data.there i am somany DTO. i am creating DTO with so many fields and assigned their data type. that DTO fields using in flex application.

                 

                Thanks

                 

                B.venkatesan

                • 5. Re: how to avoid  save same employee name under same company name
                  r4raghs

                  why dont't you ask in brief ? much complicated to read the whole thing.

                  • 6. how to avoid  specified is out of bounds error in flex 4 mxml web application
                    Venkatesan Balasubramanian Level 1

                    hi raghs,

                     

                     

                    i want to add records in cloud.bt while adding the records if we enter existing record details and try to save again na it wont allow to that record.

                     

                    that time the alert box  should show this msg "This record is already existing record in cloud database.

                     

                    ex: one company name called mobile. i am adding a employee name called raja now i save this record,its data saved in     cloud DTO

                      again try to add same employee name raja under the same compny means it should through error.

                     

                    I am give my code here please if any suggession tel.


                    CODE:

                     

                    private function saveRecord():void
                            {
                                refreshRecords();
                                model.employeeDetailsReq=new EMPLOYEEDETAILS_DTO();
                                {
                                    var lengthindex:uint=model.employeeDetailsReqRecordsList.length;
                                    var i:int;
                                    for (i = 0; i < lengthindex; i++)
                                    {
                                    if((model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employ ee name==customerdet.selectedItem.employeename)&&
                                         (model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employeeN  umber==customerdet.selectedItem.employeeID)){
                                        Alert.show("you cannot Add Same CustomerName and Invoiceno again");

                    (when this line come the error through like this: Index '8' specified is out of bounds.
                                   

                                    }

                    else

                    {

                     

                    var dp:Object=employeedet.dataProvider;            

                    var cursor:IViewCursor=dp.createCursor();
                    var employeename:String = employeename.text;


                             model.employeeDetailsReq.employename = employeename;

                    model.employeeDetailsReq.employeeNumber=cursor.current.employeeID;

                    var sendRecordToLocID:QuickBaseEventStoreRecord = new
                                        QuickBaseEventStoreRecord(model.employeeDetailsReq, new
                                            KingussieEventCallBack(refreshList))
                                    sendRecordToLocID.dispatch();

                    }

                     

                    <mx:Button  id="btnAdd" x="33" y="419" enabled="false" label="Add" width="65"  fontFamily="Georgia" fontSize="12" click="saveRecord()"/>


                    employeename and employeeID are datafields of datagrid. datagrid id=customerdet

                     

                    employeeDetailsReqRecordsList---recordlist of save records

                     

                    Thanks,

                     

                    B.venkatesan