Exemplo n.º 1
0
        private void BtnAddOrderItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                var frm = new Form_LovProductMuti();
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    DataRow dr;
                    foreach (DataRow row in frm.dtResultProduct.Rows)
                    {
                        DataRow[] results = dtBomItem.Select($"product_code = '{row[ConstColumns.PRODUCT_CODE]}' ");

                        if (results.Length == 0)
                        {
                            dr = dtBomItem.NewRow();
                            dr[ConstColumns.PRODUCT_CODE] = row[ConstColumns.PRODUCT_CODE];
                            dr[ConstColumns.PRODUCT_NAME] = row[ConstColumns.PRODUCT_NAME];
                            dr[ConstColumns.MUTIPLY_QTY]  = 1;
                            dr[ConstColumns.MUTIPLY_WGH]  = 1;
                            dtBomItem.Rows.Add(dr);
                            dtBomItem.AcceptChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BtnAddOrderItem_Click(object sender, System.EventArgs e)
        {
            //var frm = new Form_OrderDetail();
            //frm.qtyWgh = 0;
            //frm.orderDate = dtpRequestDate.Value;
            //if (frm.ShowDialog() == DialogResult.OK)
            //{
            //    DataRow dr;
            //    dr = dtOrderItem.NewRow();

            //    dr[ConstColumns.SEQ] = 0;
            //    dr[ConstColumns.PRODUCT_CODE] = frm.productCode;
            //    dr[ConstColumns.PRODUCT_NAME] = frm.productName;
            //    dr[ConstColumns.QTY_WGH] = frm.qtyWgh;
            //    dr[ConstColumns.ISSUE_UNIT_METHOD] = frm.issueUnitMethod;
            //    dr[ConstColumns.UNIT_CODE] = frm.unitCode;
            //    dr[ConstColumns.UNIT_NAME] = frm.unitName;
            //    dtOrderItem.Rows.Add(dr);
            //    dtOrderItem.AcceptChanges();
            //}
            try
            {
                var frm = new Form_LovProductMuti();
                frm.forSaleFlag  = true;
                frm.customerCode = cboCustomer.SelectedValue.ToString();
                frm.requestDate  = dtpRequestDate.Value;
                frm.classId      = CustomerController.GetCustomerClassId(frm.customerCode, frm.requestDate);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    DataRow dr;
                    foreach (DataRow row in frm.dtResultProduct.Rows)
                    {
                        DataRow[] results = dtOrderItem.Select($"product_code = '{row[ConstColumns.PRODUCT_CODE]}' ");
                        if (results.Length == 0)
                        {
                            dr = dtOrderItem.NewRow();
                            dr[ConstColumns.SEQ]               = 0;
                            dr[ConstColumns.PRODUCT_CODE]      = row[ConstColumns.PRODUCT_CODE];
                            dr[ConstColumns.PRODUCT_NAME]      = row[ConstColumns.PRODUCT_NAME];
                            dr[ConstColumns.QTY]               = 0;
                            dr[ConstColumns.UNIT_CODE_QTY]     = row[ConstColumns.UNIT_CODE_QTY];
                            dr[ConstColumns.UNIT_NAME_QTY]     = row[ConstColumns.UNIT_NAME_QTY];
                            dr[ConstColumns.WGH]               = 0;
                            dr[ConstColumns.UNIT_CODE_WGH]     = row[ConstColumns.UNIT_CODE_WGH];
                            dr[ConstColumns.UNIT_NAME_WGH]     = row[ConstColumns.UNIT_NAME_WGH];
                            dr[ConstColumns.ISSUE_UNIT_METHOD] = row[ConstColumns.ISSUE_UNIT_METHOD];
                            dr[ConstColumns.PACKING_SIZE]      = row[ConstColumns.PACKING_SIZE];

                            dtOrderItem.Rows.Add(dr);
                            dtOrderItem.AcceptChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }