Ejemplo n.º 1
0
        private Herb ComposeHerb(string name, int weight, string unit, string rate)
        {
            Herb hb = new Herb();

            hb.Name   = name;
            hb.Weight = weight;
            hb.Unit   = unit;
            hb.Rate   = rate;

            return(hb);
        }
Ejemplo n.º 2
0
        private void GVaddrows(DataGridView GV, Herb Herb)
        {
            DataGridViewRowCollection gvRows = GV.Rows;

            //有比例的Column
            if (GV.ColumnCount == 4)
            {
                gvRows.Add(new Object[] { Herb.Name, Herb.Weight, Herb.Unit, Herb.Rate });
            }
            else
            {
                gvRows.Add(new Object[] { Herb.Name, Herb.Weight, Herb.Unit });
            }
        }
Ejemplo n.º 3
0
        private List <Herb> ConvertGVRowstoHerbList(DataGridView GV)
        {
            //將DGV rows 轉換成List<Herb> 須重購
            var         rowList = GV.Rows.Cast <DataGridViewRow>().ToList();
            List <Herb> listhb  = new List <Herb>();

            foreach (var row in rowList)
            {
                Herb hb = new Herb();
                hb.Name   = row.Cells[0].Value.ToString();
                hb.Weight = Convert.ToInt32(row.Cells[1].Value);
                hb.Unit   = row.Cells[2].Value.ToString();
                listhb.Add(hb);
            }
            ;

            return(listhb);
        }