Announcement

Collapse
No announcement yet.

Problem adding records in GRID

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem adding records in GRID

    Hi there, I would like you to help me solve this, please:

    Click image for larger version

Name:	ezgif-3-3125d2a76341.gif
Views:	232
Size:	947.6 KB
ID:	306365

    What I need is that when the same products are added, that new ones are not added, but rather that they are added. I am using SQLite 3.


    This is the code I have to enter products by barcode:

    Code:
    b = Input.GetText("barcode");
    
    if b > "1000000" and b <= "9999999" then
    
    for row in db:nrows("SELECT * FROM Products where Code="..b.."") do
    
    if b == (row.Code) then
    
    Input.SetText("barcode", "");
    Page.SetFocus("barcode")
    
    nRowID = Grid.InsertRow("GridSales", -1, false);
    Grid.SetCellText("GridSales", nRowID, 0, row.Code, false);
    Grid.SetCellText("GridSales", nRowID, 1, row.Name, false);
    Grid.SetCellText("GridSales", nRowID, 2, row.SalePrice, false);
    Grid.SetCellText("GridSales", nRowID, 3, "1", false);
    Grid.SetCellText("GridSales", nRowID, 4, "0", false);
    
    
    
    --Column 2 * Column 3 = Column 4
    
    value = Grid.GetCellText("GridSales", nRowID, 2);
    amount = Grid.GetCellText("GridSales", nRowID, 3);
    multiplication = value * amount;
    Grid.SetCellText("GridSales", nRowID, 4, multiplication, true);
    
    
    
    --Column 4 (Sum)
    
    cell_value = 0;
    for x = 1, Grid.GetRowCount ("GridSales")-1 do
    if Grid.GetCellText ("GridSales", x, 4) ~= "" and String.ToNumber(Grid.GetCellText ("GridSales", x, 4)) ~= 0 then
    cell_value = cell_value + String.ToNumber (Grid.GetCellText ("GridSales", x, 4))
    end
    end
    Input.SetText("total", Math.Round(cell_value, false));
    
    
    
    
    --************************************************** ********************************
    Grid.SetEnabled("GridSales", true);
    Grid.Refresh("GridVentas");
    
    --************************************************** *******************************
    
    end
    end
    end
    Thanks.


    -----


    I don't speak English, I used Google Translate.


  • #2
    I need you to increase the quantity when same products are added.

    Comment


    • #3
      I think you will have to post an example apz with database attached for someone to look at.
      At the moment you are selecting from database and just adding a new line to grid ???,
      should be adding to database with a record id

      Comment


      • #4
        Originally posted by colc View Post
        I think you will have to post an example apz with database attached for someone to look at.
        At the moment you are selecting from database and just adding a new line to grid ???,
        should be adding to database with a record id
        That's right, I am adding each record in the last Row.
        But I don't think it is necessary to publish the apz, since with the code that I leave above it is more than enough (I think).

        Comment


        • #5
          Originally posted by colc View Post
          I think you will have to post an example apz with database attached for someone to look at.
          At the moment you are selecting from database and just adding a new line to grid ???,
          should be adding to database with a record id
          I share the project so that you can help me. I removed unnecessary things.

          Thanks!
          Attached Files

          Comment


          • #6
            I share the project so that you can help me. I removed unnecessary things.
            After many hours of work, as I do not use Gtrid Objects I think I have found your solution
            It would be much better if Grid had a Get Selected and Set Selected function
            See if this works for you
            Copy of Ronaldo2018_Project.apz

            Comment


            • #7
              Originally posted by colc View Post

              After many hours of work, as I do not use Gtrid Objects I think I have found your solution
              It would be much better if Grid had a Get Selected and Set Selected function
              See if this works for you
              Wow friend, of course it works for me. And your time to help me is greatly appreciated. Thank you so so so much!

              ---

              I realized that when I add a product and then another product, and add the first one again, an error occurs. But I'll give it a spin, if I fix it I'll post it here. Greetings, friend. (Google translate)

              Comment


              • #8
                I have no probs with the copy I posted
                Click image for larger version

Name:	Roland Pic.png
Views:	142
Size:	135.2 KB
ID:	306409

                Comment


                • #9
                  Originally posted by colc View Post
                  I have no probs with the copy I posted
                  At one point it begins to increase the amount by 2.

                  Comment


                  • #10
                    Originally posted by colc View Post
                    I have no probs with the copy I posted
                    COLC made some changes and it worked very well. For those who want it, here it is.

                    All credits to him.



                    Attached Files

                    Comment

                    Working...
                    X