예제 #1
0
파일: TabkOpen.cs 프로젝트: ranyaof/ongaz
        private void btnOpenTank_Click(object sender, EventArgs e)
        {
            using (GazOnDevEntities db = new GazOnDevEntities())
            {
                if (edit)
                {

                    db.Attach(newrecord);
                    db.ObjectStateManager.ChangeObjectState(newrecord, EntityState.Modified);

                }else
                {
                newrecord = new Tank_Stocks();
                newrecord.TankNumber = txtTankNumber.Text;
                newrecord.type = comboBox1.SelectedIndex.ToString();
                newrecord.Datetime = txtdate1.Text;
                newrecord.GazCompanyName = txtGazCompanyName.Text;
                newrecord.GazCompanyAddress = txtGazCompanyAddress.Text;
                newrecord.GazDistributor = txtGazDistributor.Text;
                if (!string.IsNullOrEmpty(txtYear_of_manufacture.Text))
                {
                    newrecord.Year_of_manufacture = Convert.ToInt32(txtYear_of_manufacture.Text);
                }
                newrecord.Date_of_Fix = Date_Of_Fix.Text;
                newrecord.manufacture_name = txtmanufacture_name.Text;
                if (!string.IsNullOrEmpty(txt_Tank_Size.Text))
                {
                    newrecord.Tank_Size = txt_Tank_Size.Text;
                }
                if (!string.IsNullOrEmpty(txtLabel_Number.Text))
                {
                newrecord.Label_Number =Convert.ToInt32(txtLabel_Number.Text);
                }
                newrecord.Address_Tank_From = txt_tank_fromAddress.Text;
                if (!string.IsNullOrEmpty(txtNumberOfZoklokPort.Text))
                {
                    newrecord.NumberOfZoklokPort = Convert.ToInt32(txtNumberOfZoklokPort.Text);
                 }
                newrecord.tankStatus = combotankStatus.SelectedIndex.ToString();
                newrecord.TankWithBase_baton = checkBox1.Checked ? true : false;
                // means that enabled at the stock
                newrecord.TankSystemStatus = "1";
                db.AddToTank_Stocks(newrecord);

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

                    }
                if (db.SaveChanges() > 0)
                {
                    MessageBox.Show("פעולת ההוספה הצליחה");

                }
                else
                {

                }
            }
        }
예제 #2
0
        private void btnOpenTank_Click(object sender, EventArgs e)
        {
            using (GazOnDevEntities db = new GazOnDevEntities())
            {

                if (string.IsNullOrEmpty(txtTankNumber.Text))
                {
                    MessageBox.Show("מספר צובר ריק נא להכניס מספר צובר תקין");
                    txtTankNumber.Text = "";
                    txtTankNumber.Focus();
                    return;
                }
                if(null !=newrecord)
                {

                if (string.IsNullOrEmpty(newrecord.TankNumber))
                {
                    MessageBox.Show("מספר צובר ריק נא להכניס מספר צובר תקין");
                    txtTankNumber.Text = "";
                    txtTankNumber.Focus();
                    return;
                }
                }
                if (null == newrecord)
                {
                    edit = false;
                }
                if (edit)
                {

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

                        db.Attach(newrecord);
                        db.ObjectStateManager.ChangeObjectState(newrecord, EntityState.Modified);

                }
                else
                {

                    newrecord = new Tank_Stocks();
                }

                    newrecord.TankNumber = txtTankNumber.Text;
                    newrecord.TankFixNumber = txtfixnumber.Text;
                    newrecord.type = comboBox1.SelectedIndex.ToString();
                    newrecord.Datetime = txtdate1.Text;
                    newrecord.GazCompanyName = txtGazCompanyName.Text;
                    newrecord.GazCompanyAddress = txtGazCompanyAddress.Text;
                    newrecord.GazDistributor = txtGazDistributor.Text;
                    if (!string.IsNullOrEmpty(txtYear_of_manufacture.Text))
                    {
                        newrecord.Year_of_manufacture = Convert.ToInt32(txtYear_of_manufacture.Text);
                    }
                    newrecord.Date_of_Fix = Date_Of_Fix.Text;
                    newrecord.manufacture_name = txtmanufacture_name.Text;
                    if (!string.IsNullOrEmpty(txt_Tank_Size.Text))
                    {
                        newrecord.Tank_Size =txt_Tank_Size.Text;
                    }
                    if (!string.IsNullOrEmpty(txtLabel_Number.Text))
                    {
                        newrecord.Label_Number = Convert.ToInt32(txtLabel_Number.Text);
                    }
                    newrecord.Address_Tank_From = txt_tank_fromAddress.Text;
                    if (!string.IsNullOrEmpty(txtNumberOfZoklokPort.Text))
                    {
                        newrecord.NumberOfZoklokPort = Convert.ToInt32(txtNumberOfZoklokPort.Text);
                    }
                    newrecord.tankStatus = combotankStatus.SelectedIndex.ToString();
                    newrecord.TankWithBase_baton = checkBox1.Checked ? true : false;
                    // means that enabled at the stock
                    //status 2 means that the tank is ready for fix and not in the stock
                    if (newrecord.TankSystemStatus != "3")
                    {
                        newrecord.TankSystemStatus = "2";
                    }

                    //signed person
                    if (!string.IsNullOrEmpty(txtName_of_recipient.Text))
                    {
                        newrecord.PersonRecipetsignName = txtName_of_recipient.Text;
                    }
                    if (!string.IsNullOrEmpty(txtSign_of_recipient.Text))
                    {
                        newrecord.PersonRecipetsignSigniture = txtSign_of_recipient.Text;
                    }

                    // transport Company

                    if (!string.IsNullOrEmpty(txtTransportCompany.Text))
                    {
                        newrecord.TransportCompanyName = txtTransportCompany.Text;
                    }
                    if (!string.IsNullOrEmpty(txtTransporterName.Text))
                    {
                        newrecord.TransportCompanyTransportername = txtTransporterName.Text;
                    }
                    if (!string.IsNullOrEmpty(txtCarNumber.Text))
                    {
                        newrecord.CarNumber = txtCarNumber.Text;
                    }
                    if (!edit)
                    {
                        dbconf.tanknumber = (Convert.ToInt32(dbconf.tanknumber) + 1).ToString();
                        dbconf.tankfixformnum = (Convert.ToInt32(dbconf.tankfixformnum) + 1).ToString();
                        db.Attach(dbconf);
                        db.ObjectStateManager.ChangeObjectState(dbconf, EntityState.Modified);

                        db.AddToTank_Stocks(newrecord);
                    }

                if (db.SaveChanges() > 0)
                {
                      MessageBox.Show("פעול  הצליחה");
                    //foreach (Control item in this.Controls)
                    //{
                    //    item.Enabled = false;
                    //    //if(item.)

                    //}
                    //btnOpenTank.Enabled = false;

                }

            }
        }