public void deleteImportTicket(im_ticket _im_ticket)
        {
            Table <im_ticket> kkk = data.GetTable <im_ticket>();

            kkk.DeleteOnSubmit(_im_ticket);
            data.SubmitChanges();
        }
        public int insertImportTicket(im_ticket _im_ticket)
        {
            Table <im_ticket> im_ticket = data.GetTable <im_ticket>();

            im_ticket.InsertOnSubmit(_im_ticket);
            data.SubmitChanges();
            return(_im_ticket.id_im_ticket);
        }
        public void updateImportTicket(im_ticket _im_ticket)
        {
            Table <im_ticket> im_tickets = data.GetTable <im_ticket>();
            im_ticket         im_ticket  = im_tickets.Single <im_ticket>(im => im.id_im_ticket == _im_ticket.id_im_ticket);

            im_ticket.date_im       = _im_ticket.date_im;
            im_ticket.id_accountant = _im_ticket.id_accountant;
            im_ticket.id_shipper    = _im_ticket.id_shipper;
            im_ticket.id_storager   = _im_ticket.id_storager;
            im_ticket.id_write      = _im_ticket.id_write;
            data.SubmitChanges();
            // return im_ticket.Equals(_im_ticket);
        }
示例#4
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            im_ticket im_ticket = new im_ticket();

            im_ticket.date_im       = (new DateTime(dateTimeInput1.Value.Year, dateTimeInput1.Value.Month, dateTimeInput1.Value.Day));
            im_ticket.id_accountant = (int)textBoxUITypeEditor4.Tag;
            im_ticket.id_write      = (int)textBoxUITypeEditor2.Tag;
            im_ticket.id_shipper    = (int)textBoxUITypeEditor1.Tag;
            im_ticket.id_storager   = (int)textBoxUITypeEditor3.Tag;
            int             idTicket = im.insertImportTicket(im_ticket);
            bool            d        = true;
            List <shipment> l        = new List <shipment>();

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                shipment shipment = new shipment();
                try
                {
                    shipment.id_im_ticket  = idTicket;
                    shipment.id_item       = (int)row.Cells[0].Value;
                    shipment.number        = Convert.ToInt32(row.Cells[2].Value);
                    shipment.unit          = row.Cells[3].Value.ToString();
                    shipment.ex_unit_price = Convert.ToDouble(row.Cells[5].Value);
                    shipment.im_unit_price = Convert.ToDouble(row.Cells[4].Value);
                    shipment.man_date      = Convert.ToDateTime(row.Cells[6].Value);
                    shipment.exp_date      = Convert.ToDateTime(row.Cells[7].Value);
                    shipment.posion        = row.Cells[8].Value.ToString();
                    l.Add(shipment);
                }
                catch {
                    MessageBox.Show("Có gì đó không ổn!");
                    im.deleteImportTicket(im_ticket);
                    d = false;
                    break;
                }
            }
            if (d)
            {
                MessageBox.Show("Thành công");
                shipments.InsertShipment((IEnumerable <shipment>)l);
                DevComponents.DotNetBar.TabControl ff = (DevComponents.DotNetBar.TabControl) this.Parent.Parent;
                ff.Tabs.RemoveAt(ff.SelectedTabIndex);
            }
        }