예제 #1
0
        public void CreateOrderLine(string ItemNo, decimal Qty)
        {
            // Create Service Reference
            var service = new SalesOrderHeader_Service();

            service.UseDefaultCredentials = true;

            // Update Order lines
            int linecounter = newOrder.SalesLines.Count();

            newOrder.SalesLines = new Sales_Order_Line[200];
            newOrder.SalesLines[linecounter] = new Sales_Order_Line();

            service.Update(ref newOrder);

            var line1 = newOrder.SalesLines[linecounter];

            line1.Type     = WSSalesOrderHeader.Type.Item;
            line1.No       = ItemNo;
            line1.Quantity = Qty;

            try
            {
                service.Update(ref newOrder);
            }
            catch (Exception ex)
            {
                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
            }
        }
예제 #2
0
        public void CreateNewOrder(string CustomerNo)
        {
            // Create Service Reference
            var service = new SalesOrderHeader_Service();

            service.UseDefaultCredentials = true;

            // Create the Order header
            newOrder = new SalesOrderHeader();
            service.Create(ref newOrder);

            // Update Order header
            newOrder.Sell_to_Customer_No  = CustomerNo;
            newOrder.Salesperson_Code     = Globals.theSalesPersonCode;
            newOrder.Location_Code        = Globals.theLocation;
            newOrder.External_Document_No = GetDefaultExtDocNo();
            service.Update(ref newOrder);

            orderno = newOrder.No;

            tbName.Text     = newOrder.Sell_to_Customer_No;
            tbName2.Text    = newOrder.Sell_to_Customer_Name;
            tbAddress.Text  = newOrder.Sell_to_Address;
            tbAddress2.Text = newOrder.Sell_to_Address_2;
            tbPostCode.Text = newOrder.Sell_to_Post_Code;
            tbCity.Text     = newOrder.Sell_to_City;
            tbPhone.Text    = newOrder.Sell_to_Contact_Phone_No;
            tbEmail.Text    = newOrder.Sell_to_Contact_E_Mail;

            tbExternalDoc.Text   = newOrder.External_Document_No;
            mtbShipmentDate.Text = newOrder.Shipment_Date.ToShortDateString();
        }
예제 #3
0
        private void cbDeliverycode_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbDeliverycode.Text           = this.cbDeliverycode.GetItemText(this.cbDeliverycode.SelectedItem);
            newOrder.Shipment_Method_Code = cbDeliverycode.Text;

            var service = new SalesOrderHeader_Service();

            service.UseDefaultCredentials = true;

            service.Update(ref newOrder);
        }
예제 #4
0
        private void btSaveAndClose_Click(object sender, EventArgs e)
        {
            // Create Service Reference
            var service = new SalesOrderHeader_Service();

            service.UseDefaultCredentials = true;

            // Update Order header
            newOrder.Shipment_Date        = DateTime.Parse(mtbShipmentDate.Text.ToString());
            newOrder.External_Document_No = tbExternalDoc.Text;
            service.Update(ref newOrder);

            this.Close();
        }
예제 #5
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((keyData == Keys.Enter) && (dataGridView1.Focused))
            {
                if (dataGridView1.CurrentRow == null)
                {
                    return(true);
                }

                int CurIndex = dataGridView1.CurrentRow.Index;

                // kald edit formen med linjen som ref param.

                var     salesline = newOrder.SalesLines[CurIndex];
                decimal antal     = newOrder.SalesLines[CurIndex].Quantity;
                decimal pris      = newOrder.SalesLines[CurIndex].Unit_Price;
                decimal percent   = newOrder.SalesLines[CurIndex].Line_Discount_Percent;

                fmEditSalesLine editsalesline = new fmEditSalesLine();
                editsalesline.ShowDialog(ref antal, ref pris, ref percent, salesline.Description);

                // Create Service Reference
                var service = new SalesOrderHeader_Service();
                service.UseDefaultCredentials = true;

                if (antal == 0)
                {
                    if (MessageBox.Show("Vil du slette 0 linjen", "Slet Linjen?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        service.Delete_SalesLines(newOrder.SalesLines[CurIndex].Key);
                        newOrder = service.Read(orderno);
                    }
                }
                else
                {
                    salesline.Quantity = antal;
                    if (salesline.Unit_Cost_LCY > pris)
                    {
                        if (MessageBox.Show(string.Format("Købsprisen på {0}kr. ligger under den angivende salgspris på {1}kr. Vil du fortsætte med den pris?", salesline.Unit_Cost_LCY, pris), "Prisadvarsel", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                        {
                            salesline.Unit_Price = pris;
                        }
                    }
                    else
                    {
                        salesline.Unit_Price            = pris;
                        salesline.Line_Discount_Percent = percent;
                    }
                }

                service.Update(ref newOrder);

                GetSalesOrderLineData();

                if (dataGridView1.Rows.Count <= CurIndex)
                {
                    CurIndex = dataGridView1.Rows.Count - 1;
                }
                if (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.CurrentCell = dataGridView1.Rows[CurIndex].Cells[0];
                }
                else
                {
                    tbDescription.Text = "";
                }

                return(true);
            }

            if (keyData == Keys.Escape)
            {
                //this.Close();
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }