예제 #1
0
 private void lvReceipts_ItemActivate(object sender, EventArgs e)
 {
     int row_num = -1;
     if (this.lvReceipts.SelectedIndices.Count == 1)
         row_num = this.lvReceipts.SelectedIndices[0];
     //if (row_num >= 0){
     if ( this.lvReceipts.SelectedItems.Count == 1 ){
         System.Data.DataRow old_row = (System.Data.DataRow)this.lvReceipts.SelectedItems[0].Tag;
         if( old_row != null ){
             ReceiptForm rptf = new ReceiptForm(this.cConnection, ref old_row, ReceiptType.Existing);
             if (rptf.ShowDialog() == DialogResult.OK)
             {
                 this.lvReceipts.Items.Clear();
                 int i = 0;
                 foreach (System.Data.DataRow drw in this.receipts.Rows)
                 {
                     this.AddNewRow(i++, drw);
                 }
                 this.lvReceipts.SelectedIndices.Add(row_num);
                 //                    this.receipts.Rows.Add(new_row);
                 //                    this.AddNewRow(this.receipts.Rows.Count, new_row);
                 this.CalculateTotal(false);
             }
         }
         else
         {
             MessageBox.Show("Ошибка получения чека!");
         }
     }
     return;
 }
예제 #2
0
 private void tsmiNewReceipt_Click(object sender, EventArgs e)
 {
     try{
         System.Data.DataRow new_row = this.receipts.NewRow();
         new_row["Created"] = System.DateTime.Now;
         new_row["Updated"] = System.DateTime.Now;
         ReceiptForm rptf = new ReceiptForm(this.cConnection, ref new_row, ReceiptType.New);
         if (rptf.ShowDialog() == DialogResult.OK)
         {
             this.receipts.Rows.Add(new_row);
             this.AddNewRow(this.receipts.Rows.Count - 1, new_row);
             this.CalculateTotal(false);
         }
     }catch(System.Exception ex ){
         MessageBox.Show("Ошибка при создании нового чека:\n" + ex.Message);
     }
     return;
 }
예제 #3
0
        private void CreateClonedReceipt()
        {
            int row_num = -1;
            if (this.lvReceipts.SelectedIndices.Count == 1)
                row_num = this.lvReceipts.SelectedIndices[0];
            if (this.lvReceipts.SelectedItems.Count == 1)
            {
                System.Data.DataRow org_rcpt = (System.Data.DataRow)this.lvReceipts.SelectedItems[0].Tag;
                if (org_rcpt != null)
                {
                    System.Data.DataRow new_rcpt = this.receipts.NewRow();
                    foreach (System.Data.DataColumn col in this.receipts.Columns)
                    {
                        new_rcpt[col] = org_rcpt[col];
                    }
                    new_rcpt["Created"] = System.DateTime.Now;
                    new_rcpt["Updated"] = System.DateTime.Now;

                    this.receipts.Rows.Add(new_rcpt);
                    this.AddNewRow(this.receipts.Rows.Count - 1, new_rcpt);
                    this.CalculateTotal(false);

                    ReceiptForm rptf = new ReceiptForm(this.cConnection, ref new_rcpt, ReceiptType.Cloned);
                    if (rptf.ShowDialog() == DialogResult.OK)
                    {
                        this.lvReceipts.Items.Clear();
                        int i = 0;
                        foreach (System.Data.DataRow drw in this.receipts.Rows)
                        {
                            this.AddNewRow(i++, drw);
                        }
                        this.lvReceipts.SelectedIndices.Add(row_num);

                        this.CalculateTotal(false);
                    }
                }
                else
                {
                    MessageBox.Show("Ошибка получения чека!");
                }
            }
            return;
        }