Example #1
0
        private void CopySheet()
        {
            DataRow dr = this.dataGrid1.CurrentRow();

            body.SheetCopy sheetCopy = new body.SheetCopy();
            sheetCopy.details = new List <body.SheetCopy.SheetDetail>();
            sheetCopy         = sheetCopy.DataRowToModel(dr);

            sheetCopy.memo       = dr["payfee_memo"].ToString();
            sheetCopy.supcust_no = dr["cust_no"].ToString();

            foreach (DataRow r in this.dataGrid2.DataSource.Rows)
            {
                body.SheetCopy.SheetDetail sheetDetail = new body.SheetCopy.SheetDetail();
                sheetDetail = sheetDetail.DataRowToModel(r);
                sheetCopy.details.Add(sheetDetail);
            }

            ClipboardHelper.SetData(sheetCopy);
        }
        private void SheetPaste()
        {
            body.SheetCopy sheetCopy = new body.SheetCopy();
            sheetCopy = ClipboardHelper.GetData(sheetCopy);

            if (sheetCopy.details != null && sheetCopy.details.Count > 0)
            {
                int index = 0;
                if (this.editGrid1.CurrentRow() != null)
                {
                    for (int i = 0; i < this.editGrid1.DataSource.Rows.Count; i++)
                    {
                        if (this.editGrid1.DataSource.Rows[i] == this.editGrid1.CurrentRow())
                        {
                            index = i;
                        }
                    }
                }

                foreach (body.SheetCopy.SheetDetail detail in sheetCopy.details)
                {
                    DataRow dr = this.editGrid1.DataSource.NewRow();

                    detail.DataModelToRow(dr);

                    this.editGrid1.DataSource.Rows.InsertAt(dr, index);
                    index++;
                }

                if (!string.IsNullOrEmpty(this.editGrid1.DataSource.Rows[this.editGrid1.DataSource.Rows.Count - 1]["item_subno"].ToString()))
                {
                    this.editGrid1.DataSource.Rows.Add();
                }

                this.editGrid1.Editing = false;
                this.editGrid1.Refresh();
            }
        }