public void Create(Order_articleFK order_articleFK)
 {
     try
     {
         Database.Connect();
         command = new OdbcCommand
         {
             Connection  = Database.GetConn(),
             CommandType = CommandType.StoredProcedure,
             CommandText = "{call csg.Order_articleFK_Create(?,?,?,?,?)}"
         };
         command.Parameters.Add("Order", OdbcType.VarChar, 50).Value   = order_articleFK.Order_number;
         command.Parameters.Add("Article", OdbcType.VarChar, 50).Value = order_articleFK.Article_code;
         //Agregar 3 campos por si es tanque o hidro
         command.Parameters.Add("Model", OdbcType.VarChar, 50).Value  = order_articleFK.Model;
         command.Parameters.Add("Esp", OdbcType.VarChar, 50).Value    = order_articleFK.Especification;
         command.Parameters.Add("Serial", OdbcType.VarChar, 50).Value = order_articleFK.Serial;
         command.ExecuteNonQuery();
         Console.WriteLine("CREATE-> order: " + order_articleFK.Order_number + " | article: " + order_articleFK.Article_code);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Excepción controlada en Order_articleFKDAO->Create: " + ex.Message, "Excepción", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         Database.Disconnect();
     }
 }
Exemple #2
0
        //Evento del botón "Crear"
        private void IbtnCreate_Click(object sender, EventArgs e)
        {
            if (ValidateFields())
            {
                Order order = new Order();
                order.Order_number         = txtNumber.Text;
                order.Order_reception_date = DateTime.Parse(dtpDateReception.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                order.Order_type           = cboType.Text;
                order.Order_invoice        = txtInvoice.Text;
                if (txtInvoice.Enabled)
                {
                    order.Order_sale_date = dtpSaleDate.Value;
                }
                //order.Order_comentarys = ""; -> Por definir funcionalidad
                order.Order_report_client = txtReportClient.Text;
                //Técnico
                Technician t = technicianLog.Read_once(txtTechnicianId.Text);
                order.Technician = t;
                //Cliente
                Client c = clientLog.Read_once(txtClientId.Text);
                order.Client = c;
                //Cotización
                //Creamos cotización
                Cotization cotization = new Cotization
                {
                    Cotization_id = "CT-" + PrOrder[cboType.SelectedIndex] + "" + orderLog.Read_count().ToString()
                };
                cotizationLog.Create(cotization);
                //Consultamos la cotización
                Cotization cn = cotizationLog.Read_once(cotization.Cotization_id);
                //MessageBox.Show("Cotizacion: " + cn.Cotization_id);
                order.Cotization = cn;
                //Capturamos el usuario que creará la orden
                order.Create_by = UserCache.UserAccount;                                          //Enviar desde el DAO
                //Capturamos el momento de la creacion
                order.Create_date = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //Desde el DAO mejor
                //Creación de orden
                orderLog.Create(order);
                //Creamos el order_article para que asigne el artículo sobre el cual se va a operar
                //En una orden van n articulos, estos se definen en la tabla
                //for (int i = 0; i < dtoa.Rows.Count; i++)
                //{
                Order_articleFK order_articleFK = new Order_articleFK
                {
                    Order_number   = order.Order_number,
                    Article_code   = txtArticleCod.Text,
                    Model          = txtArticleModel.Text,
                    Especification = txtArticleEsp.Text,
                    Serial         = txtArticleSerial.Text
                };
                orderArticleLog.Create(order_articleFK);
                //}

                //Enviamos al caché la variable numero de orden
                Order.Order_number_st = order.Order_number;
                ViewReportOrderCreate();
                ResetControls(sender, e);
            }
        }
        private void AddArticles()
        {
            Order_articleFK oa      = orderArticleLog.Read_ArticleOfOrder(Order.Order_number_st);
            Article         article = articleLog.Read_once(oa.Article_code);

            txtArticleCode.Text   = oa.Article_code;
            txtArticleDesc.Text   = article.Article_description;
            txtArticleModel.Text  = oa.Model;
            txtArticleEsp.Text    = oa.Especification;
            txtArticleSerial.Text = oa.Serial;
        }
        private void FrmCotizationCreate_Load(object sender, EventArgs e)
        {
            //Estado de los controles del formulario
            txtServiceCode.Focus();
            //Consultamos la orden requerida. pruebas con RL-15
            string order_number = Order.Order_number_st;

            order                   = orderLog.Read_once(order_number);
            txtOrder.Text           = order.Order_number;
            dtpReception_date.Value = order.Order_reception_date;
            txtOrderType.Text       = order.Order_type;
            txtOrderState.Text      = order.Order_state;
            //Agregamos el objeto Technician
            txtTechnicianName.Text      = order.Technician.Technician_name;
            txtTechnicianTelephone.Text = order.Technician.Technician_telephone;
            txtTechnicianContact.Text   = order.Technician.Technician_contact;
            //Consultamos el código del equipo asignado a la orden en order_article
            string code = orderArticleLog.Read_code_article_of_order(order.Order_number);
            //Consultamos el artículo con el código de orden anterior
            Article article = articleLog.Read_once(code);

            txtArticleCode.Text        = article.Article_code;
            txtArticleDescription.Text = article.Article_description;
            Category category = categoryLog.Read_once(article.Category);

            txtCategory.Text = category.Category_name;
            //Consultamos en order article para traer el modelo->nro lote, especificacion y serial
            Order_articleFK order_ArticleFK = orderArticleLog.Read_ArticleOfOrder(order_number);

            txtArticleModel.Text  = order_ArticleFK.Model;
            txtArticleEsp.Text    = order_ArticleFK.Especification;
            txtArticleSerial.Text = order_ArticleFK.Serial;
            //Agregamos el campo report client
            txtReportClient.Text = order.Order_report_client;
            AutoCompleteService();
            AutoCompleteRefaction();
            CreateDataTables();
            //Console.WriteLine("IVA: " + taxLog.Read_once_value("19"));
            //Cargamos los articulos asociados a la orden
            //LoadArticlesOfOrder();
        }
        public List <Order_articleFK> Read_ArticlesOfOrder(string order_number)
        {
            List <Order_articleFK> order_Articles = new List <Order_articleFK>();

            try
            {
                Database.Connect();
                command = new OdbcCommand
                {
                    Connection  = Database.GetConn(),
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "{call csg.Order_articleFK_ReadArticlesOfOrder(?)}"
                };
                command.Parameters.Add("OrderNumber", OdbcType.VarChar, 50).Value = order_number;
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    Order_articleFK order_ArticleFK = new Order_articleFK
                    {
                        Order_number   = order_number,
                        Article_code   = dataReader.GetString(0),
                        Model          = dataReader.GetString(1),
                        Especification = dataReader.GetString(2),
                        Serial         = dataReader.GetString(3)
                    };
                    order_Articles.Add(order_ArticleFK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Excepción controlada en Order_articleFKDAO->Read_ArticlesOfOrder: " + ex.Message, "Excepción", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Database.Disconnect();
            }
            return(order_Articles);
        }
Exemple #6
0
 public void Create(Order_articleFK order_articleFK)
 {
     DAOFactory.GetOrder_ArticleFKDAO().Create(order_articleFK);
 }