Exemple #1
0
        public bool IncluirCliente()
        {
            ClasseBanco csBanco = new ClasseBanco();

            string iCodigoCliente = this.ProximoCodigoCliente(csBanco);

            string sCampos = "CodCli, Ativo, Cliente, Fornecedor, Prospect, RazSoc, NomFan, CGC_CPF, RgCli, EndCli, Numero, Bairro, CidCli, Complemento," +
            "Cep, Celular, Contato, DatCad, Email, EstCli, FaxCli, RamCli, TelCli, TipoCli, OBS1 ";

            string dtDataCadastro = DateTime.Today.Year + "/" + String.Format("{0:00}", DateTime.Today.Month) + "/" + String.Format("{0:00}", DateTime.Today.Day);

            string sValores = iCodigoCliente + "," +
                   "'" + this.Ativo + "','" +
                   this.bCliente + "','" +
                   this.Fornecedor + "','" +
                   this.Prospect + "','" +
                   this.RazSoc + "','" +
                   this.NomFan + "','" +
                   this.CGC_CPF + "','" +
                   this.RgCli + "','" +
                   this.EndCli + "','" +
                   this.Numero + "','" +
                   this.Bairro + "','" +
                   this.CidCli + "','" +
                   this.Complemento + "','" +
                   this.Cep + "','" +
                   this.Celular + "','" +
                   this.Contato + "','" + dtDataCadastro + "','" +
                   this.Email + "','" +
                   this.EstCli + "','" +
                   this.FaxCli + "','" +
                   this.RamCli + "','" +
                   this.TelCli + "','" +
                   this.TipoCli + "','" +
                   this.Obs1 + "'";
            
            
            sValores = Funcoes.RetiraCaracteres(sValores);

            //Insere na VENDCLI
            int iVendedor = Convert.ToInt32(Session["CodVend"]);
            int iEmpresa = Convert.ToInt32(Session["EmpresaCODEMP"]);
            int iSequencia = 1;

            csBanco.FU_Insert("VENDCLI", "CodEmp, CodCli, CodVen, TelVend_VendCli, Vend_VendCli, DataAdm", "" + iEmpresa + "," + iCodigoCliente + "," + iVendedor + ", 'N', 'S', CONVERT (datetime, GETDATE())");

            //GRAVAR CLI_OBS com as Referencias
            var r = csBanco.Query("SELECT ISNULL(MAX(CODSEQ),0) + 1 FROM CLI_OBS WHERE CODCLI = " + iCodigoCliente);
            if (r.Read())
            {
                iSequencia = Convert.ToInt16(r[0].ToString());
            }
            r.Close();

            if (this._RefBancaria != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Bancaria : " + this._RefBancaria + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefBancaria2 != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Bancaria II : " + this._RefBancaria2 + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefBancaria3 != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Bancaria III : " + this._RefBancaria3 + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefComercial != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Comercial : " + this._RefComercial + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefComercial2 != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Comercial II: " + this._RefComercial2 + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefComercial3 != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Comercial III : " + this._RefComercial3 + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefContador != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Contador : " + this._RefContador + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefContador2 != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Contador II : " + this._RefContador2 + "'");
                iSequencia = iSequencia + 1;
            }

            if (this._RefContador3 != "")
            {
                csBanco.FU_Insert("CLI_OBS", "CodSeq, CodCli, Obs", "" + iSequencia + "," + iCodigoCliente + ",'Ref. Contador III : " + this._RefContador3 + "'");
                iSequencia = iSequencia + 1;
            }
            
            //Insere cliente
            if (csBanco.FU_Insert("CLIENTE", sCampos, sValores) == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
                        
        }