0

How can i pass this method from another form to other

          public class arka_data

    {

        public int NR { get; set; }

        public int BARKODI { get; set; }

        public string EMERTIMI { get; set; }

        public int SASIA {get;set;}

        public float CMIMI {get;set;}

        public float TVSH { get; set; }

        public float TOTAL { get; set; }

        public float NENTOTALI { get; set; }

        public float ZBRITJA { get; set; }

        public float TOTALI { get; set; }

        public DateTime KOHA { get; set; }

        public string KASIERI { get; set; }

        public string KLIENTI { get; set; }

        public float VLERAETVSH { get; set; }

        public float VLERAPATVSH { get; set; }

        public int NRATIKUJVE { get; set; }

        public float TOTALIPCS { get; set; }

        public float VLERATVSHTOTAL { get; set; }





    }

    public void mbushe()

  {

       arka_data dta  = new arka_data();

       for (int i = 0; i < dataTable.Rows.Count; i++)

      {

          dta.NR = int.Parse(txtnrfatures.Text);

          dta.VLERATVSHTOTAL = float.Parse( textBox1.Text);

          dta.BARKODI = int.Parse(dataTable.Rows[i][0].ToString());

          dta.EMERTIMI = dataTable.Rows[i][1].ToString();

          dta.SASIA = int.Parse(dataTable.Rows[i][2].ToString());

          dta.CMIMI = int.Parse(dataTable.Rows[i][3].ToString());

          dta.TVSH = int.Parse(dataTable.Rows[i][4].ToString());

          dta.NENTOTALI = float.Parse(txttotali.Text);

          dta.ZBRITJA = float.Parse(txtzbritja.Text);

          dta.TOTALI = float.Parse(totali.Text);

          dta.KOHA = DateTime.Now;

          dta.KASIERI = lbluser.Text;

          dta.KLIENTI = cmbklienti.Text;

          dta.VLERAETVSH = float.Parse(dataTable.Rows[i][7].ToString());

          dta.VLERAPATVSH = float.Parse(dataTable.Rows[i][6].ToString());

          dta.NRATIKUJVE = int.Parse(lblnumri.Text);

          dta.TOTALIPCS = float.Parse(dataTable.Rows[i][5].ToString());





      }

The idea it that this class handle the data from form one , and use it(insert it into sql) on form two . How should I pass the object in another form, or how should I refer it. Also another question is the class populated correctly (from : textbox, labels and datagridview ). The method mbushe collects data , and this data should be passed one frm2. I created the method on frm1 , but don't have any clue how to cont. on. I tried Arka. Mbushe but getting this error ' is a 'method', which is not valid in the given context'The idea is that during the insertion of data on frm2 I use this data like this

           cmd.Parameters.Add(new SqlParameter("@nrfatures", mbushe.NR);

But mu question is how to get this data on frm2 and use this data during the insertion process.

  • You have already asked this question. The answer is the same as the duplicate you have already seen. Usually: public Property / public Method / class Constructor. All mentioned in the duplicate. Maybe what's missing is DataBindings. But you can find some answers about this, too. – Jimi May 26 '20 at 13:27
  • Yes I asked 2 hours ago, but didn't get any help to clarify my problem. And I have rights provided by this forum"Your post has been associated with a similar question. If this question doesn’t resolve your question, ask a new one. " This is the message I go in the first question after being closed. I didn't get any help to help me , solve me the problem – user9290729 May 26 '20 at 13:29
  • The point is that the duplicate does answer your question, you just haven't realized that yet. [Here's one using DataBindings](https://stackoverflow.com/a/57235083/7444103). – Jimi May 26 '20 at 13:31
  • I don't see any solution on that link that your give , or in the duplicate. I am trying to pass an entire object with collected data , not a tb. Passing a textbox is way way different than calling a object – user9290729 May 26 '20 at 13:34
  • Ok , thank you for your help, but didn't yet get thing clear, so I have to look somewhere else, thanks again :) – user9290729 May 26 '20 at 14:17

0 Answers0