예제 #1
0
        private void CadastroCusto(DataTable tabela)
        {
            if (tabela.Rows.Count <= 0)
            {
                return;
            }

            List <string> colunas = new List <string>();

            colunas.Add("Empresa");
            colunas.Add("DocDate");
            colunas.Add("ItemCode");
            colunas.Add("Warehouse");
            colunas.Add("CalcPrice");
            colunas.Add("TransNum");


            List <dynamic> valores = new List <dynamic>();

            DateTime adata = DateTime.Parse("30/12/2099 00:00:00");

            for (int a = 0; a < tabela.Rows.Count; a++)
            {
                valores.Add(tabela.Rows[a]["Empresa"]);
                string data = ((string)tabela.Rows[a]["DocDate"]);
                //data = data.Substring(0, 10);dat
                adata = Convert.ToDateTime(data);
                //data = data.Replace("-", "/");
                //  data = data + " 00:00:00";

                valores.Add(adata);
                valores.Add(tabela.Rows[a]["ItemCode"]);
                valores.Add(tabela.Rows[a]["Warehouse"]);

                string kj = (tabela.Rows[a]["CalcPrice"] + "").Replace(".", ",");
                if (kj == "")
                {
                    kj = "0";
                }

                valores.Add(double.Parse(kj));
                valores.Add(tabela.Rows[a]["TransNum"]);
            }


            //MySqlConnection con = Conexao.GetConnection();
            //command = conCreateCommand();

            /*
             * command.CommandText = string.Format("delete from custo");
             * sql = command.CommandText;
             * ini(sql, tipo);
             * retorno = command.ExecuteNonQuery();
             */
            ExecuteNonSql.Deletar("custo");
            if (ExecuteNonSql.Executar("custo", TipoDeOperacao.Tipo.InsertMultiplo, colunas, valores, null) != -1)
            {
                MsgBox.Show.Info("Custo Atualizado!!!");
            }
            else
            {
                MsgBox.Show.Error("Erro ao inserir");
            }
        }