示例#1
0
文件: TabkOpen.cs 项目: ranyaof/ongaz
        /*  BindingSource _bsTankOpen;
        GazOnDevEntities db2 = new GazOnDevEntities();*/
        public TabkOpen()
        {
            InitializeComponent();
            this.RightToLeft = Gizmox.WebGUI.Forms.RightToLeft.Yes;

               // _bsTankOpen = new BindingSource(typeof(Tank_Stocks), "");

            txtTankNumber.Leave += new EventHandler(txtTankNumber_Leave);

             Tank_Stocks tanktofix;
             BindingList<invoiceitem> _currentinvoiceitems = new BindingList<invoiceitem>();
             Invoice _currentinvoice = new Invoice();

            using (GazOnDevEntities db= new GazOnDevEntities())
            {

                 dbconf= db.Configdbs.FirstOrDefault();
                txtTankNumber.Text = dbconf.tanknumber;
                // must icrease id of invoice id  ;
            }
              //  textBox1.Leave += new EventHandler(textBox1_Leave);
        }
示例#2
0
        void txtinvoiceid_Leave(object sender, EventArgs e)
        {
            using (GazOnDevEntities db = new GazOnDevEntities())
             {
                 _currentinvoice = db.Invoices.FirstOrDefault(x => x.invoiceNumber == txtinvoiceid.Text);
                 if ((null != _currentinvoice) && (_currentinvoice.id > 0))
                 {
                     edit = true;
                     MessageBox.Show("תעודת משלוח עם מספר כזה קיימת  אתה עובר למצב עריכה");
                   //  havetank = Convert.ToBoolean(_currentinvoice.havetank);
                     // set buttun to disable
                     //button1.Enabled = false;
                     //btnReportPrint.Enabled = false;
                     //btnPrint.Enabled = false;
                     //btnupload.Enabled = false;
                     //foreach (Control item in dataGridView1.Controls)
                     //{
                     //    item.Enabled = false;

                     //}

                     txtAddress.Text = _currentinvoice.address;
                     txtTo.Text = _currentinvoice.C_to;
                     txtCarNum.Text = _currentinvoice.carnum;
                     DatetimePicker.Value = Convert.ToDateTime(_currentinvoice.date);
                     txtinvoiceid.Text = _currentinvoice.invoiceNumber;
                     txtCarTransporter.Text = _currentinvoice.transporter;
                     txtTankNymber.Text = _currentinvoice.tankNumber;
                     txtTankDescription.Text = _currentinvoice.tankDesc;
                     // increase invoice id number

                     var query = from p in db.invoiceitems
                                 where p.invoiceid == txtinvoiceid.Text
                                 orderby p.id ascending
                                 select p;
                     _currentinvoiceitems = new BindingList<invoiceitem>(query.ToList<invoiceitem>());

                     bindingSource1.DataSource =_currentinvoiceitems;

                 }
                 else
                 {

                 // set buttns to enable
                     edit = false;
                        //btnReportPrint.Enabled = true;
                        // btnPrint.Enabled = true;
                        // btnupload.Enabled = true;
                        // button1.Enabled = true;
                        // havetank = false;
                        // foreach (Control item in dataGridView1.Controls)
                        // {
                        //     item.Enabled = true;

                        // }

                 }
             }
        }
示例#3
0
        private void btnReportPrint_Click(object sender, EventArgs e)
        {
            using (GazOnDevEntities db = new GazOnDevEntities())
            {

                if (edit)
                {
                    db.Attach(_currentinvoice);
                    db.ObjectStateManager.ChangeObjectState(_currentinvoice, EntityState.Modified);

                    foreach (invoiceitem item in bindingSource1.List)
                    {
                        if (null != item.amount)
                        {
                            updateStockAmount(item);
                        }
                        db.Attach(item);
                        db.ObjectStateManager.ChangeObjectState(item, EntityState.Modified);
                    }
                }
                else
                {

                    foreach (invoiceitem item in bindingSource1.List)
                    {
                        //invoiceitem item = new invoiceitem();
                        ////stocklist.
                        // item.invoiceid = txtinvoiceid.Text;

                        if (null != item.amount)
                        {
                            updateStockAmount(item);
                        }
                        db.AddToinvoiceitems(item);
                    }
                }

                //}

                dbconf.invoicelastid = (Convert.ToInt32(dbconf.invoicelastid) + 1).ToString();
                db.Attach(dbconf);
                db.ObjectStateManager.ChangeObjectState(dbconf, EntityState.Modified);

                if (edit)
                {

                }
                else
                {
                    if (_currentinvoice == null)
                    {
                        _currentinvoice = new Invoice();
                    }
                    _currentinvoice.address = txtAddress.Text;
                    _currentinvoice.C_to = txtTo.Text;
                    _currentinvoice.carnum = txtCarNum.Text;
                    _currentinvoice.date = DatetimePicker.Value;
                    _currentinvoice.invoiceNumber = txtinvoiceid.Text;
                    _currentinvoice.tankNumber = tanktofix.TankNumber;
                    _currentinvoice.tankDesc = txtTankDescription.Text;
                    // increase invoice id number
                    _currentinvoice.transporter = txtCarTransporter.Text;
                    db.AddToInvoices(_currentinvoice);
                }
                if (db.SaveChanges() > 0)
                {

                    // MessageBox.Show("פעולת ההוספה הצליחה");
                    frmReportTankRecipet tanko = new frmReportTankRecipet(Convert.ToInt32(_currentinvoice.invoiceNumber), "report3");
                    tanko.ShowDialog();
                    //btnOpenTank.Enabled = false;

                }
                else
                {
                    MessageBox.Show("פעולת ההוספה נכשלה");

                }
            }
              //  btnOpenTank.Enabled = false;
              /*  frmReportTankRecipet tanko = new frmReportTankRecipet(tanktofix.Id, "report3");
            tanko.ShowDialog();*/
        }
示例#4
0
 /// <summary>
 /// Create a new Invoice object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static Invoice CreateInvoice(global::System.Int32 id)
 {
     Invoice invoice = new Invoice();
     invoice.id = id;
     return invoice;
 }
示例#5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Invoices EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToInvoices(Invoice invoice)
 {
     base.AddObject("Invoices", invoice);
 }