Esempio n. 1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            ContractSupply c = new ContractSupply();

            List <SupplyProduct> lsp = new List <SupplyProduct>();
            SupplyProduct        sp  = new SupplyProduct();

            c.wasReceived    = (bool)comboBoxWasReceived.SelectedValue;
            c.numberOfSupply = Int32.Parse(textBox2.Text);
            c.ContractorId   = (int)comboBoxContractors.SelectedValue;
            sp.ProductId     = (int)comboBoxProducts.SelectedValue;
            sp.Amount        = Int32.Parse(textBoxAmount.Text);
            lsp.Add(sp);
            c.SupplyProducts = lsp;
            c.Date           = dateTimePicker1.Value.Date;
            if (Id == -1)
            {
                query.queryAddContractSupply(c);
            }
            else
            {
                c.Id = Id;
                query.queryUpdateContractSupply(c);
            }
            instance.refreshGrid();
            this.Dispose();
        }
Esempio n. 2
0
        private void addDataForUpdate()
        {
            ContractSupply c = query.queryFindContractSupplyById(Id);

            if (c == null)
            {
                return;
            }

            /*  dateTimePicker1.Value = c.contractSupply.Date;
             * if (c.productList[0].ProductObj != null && c.productList[0].Amount != null)
             * {
             *    comboBoxProducts.SelectedValue = c.productList[0].ProductObj;
             *    textBoxAmount.Text = c.productList[0].Amount+"";
             * }
             *
             * textBox2.Text = c.contractSupply.numberOfSupply+"";
             * comboBoxWasReceived.SelectedValue = c.contractSupply.wasReceived;*/

            dateTimePicker1.Value = c.Date;
            if (c.SupplyProducts[0] != null)
            {
                comboBoxProducts.SelectedValue = c.SupplyProducts[0].ProductId;
                textBoxAmount.Text             = c.SupplyProducts[0].Amount + "";
            }
            textBox1.Text = c.Id + "";
            textBox2.Text = c.numberOfSupply + "";
            comboBoxContractors.SelectedValue = c.ContractorId;
            //comboBoxWasReceived.SelectedValue = c.wasReceived;
        }