Exemple #1
0
        public string Dao_getCdInvoice()
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetCdInvoice",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    var lReader = lCommand.ExecuteReader();
                    var lResult = "";
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            lResult = lReader["CdInvoice"].ToString();
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lResult);
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
            }
        }
        public BoCustomer Dao_getCustomerByDocument(string pNoIdentification, int pIdTypeIdentification)
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetCustomerByIdentification",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    lCommand.Parameters.Add(new SqlParameter("@NoIdentification", pNoIdentification));
                    lCommand.Parameters.Add(new SqlParameter("@IdTypeIdentification", pIdTypeIdentification));
                    var lReader   = lCommand.ExecuteReader();
                    var oCustomer = new BoCustomer();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            oCustomer.LStatus             = new BoStatus();
                            oCustomer.LObject             = new BoObject();
                            oCustomer.LTypeIdentification = new BoTypeIdentification();
                            oCustomer.LIdCustomer         = Convert.ToInt32(lReader["IdCustomer"].ToString());
                            oCustomer.LTypeIdentification.LIdTypeIdentification = Convert.ToInt32(lReader["IdTypeIdentification"].ToString());
                            oCustomer.LNoIdentification = lReader["NoIdentification"].ToString();
                            oCustomer.LNameCustomer     = lReader["NameCustomer"].ToString();
                            oCustomer.LLastNameCustomer = lReader["LastNameCustomer"].ToString();
                            oCustomer.LCreationDate     = Convert.ToDateTime(lReader["CreationDate"].ToString());
                            oCustomer.LModificationDate = Convert.ToDateTime(lReader["ModificationDate"].ToString());
                            oCustomer.LStatus.LIdStatus = lReader["IdStatus"].ToString();
                            oCustomer.LObject.LIdObject = Convert.ToInt32(lReader["IdObject"].ToString());
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(oCustomer);
                }
                catch (Exception e)
                {
                    var oCustomer = new BoCustomer {
                        LException = e.Message
                    };
                    if (e.InnerException != null)
                    {
                        oCustomer.LInnerException = e.InnerException.ToString();
                    }
                    oCustomer.LMessageDao = BoErrors.MsgErrorGetSql;
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(oCustomer);
                }
            }
        }
Exemple #3
0
        public BoInvoice Dao_getInvoiceById(int pIdInvoice)
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                var lInvoice = new BoInvoice();
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetInvoice",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    lCommand.Parameters.Add(new SqlParameter("IdInvoice", pIdInvoice));

                    var lReader = lCommand.ExecuteReader();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            lInvoice.LStatus                     = new BoStatus();
                            lInvoice.LObject                     = new BoObject();
                            lInvoice.LCustomer                   = new BoCustomer();
                            lInvoice.LListInvoiceItem            = new List <BoInvoiceItem>();
                            lInvoice.LIdInvoice                  = Convert.ToInt32(lReader["IdInvoice"].ToString());
                            lInvoice.LCdInvoice                  = lReader["CdInvoice"].ToString();
                            lInvoice.LCreationDate               = Convert.ToDateTime(lReader["CreationDate"].ToString());
                            lInvoice.LCustomer.LIdCustomer       = Convert.ToInt32(lReader["IdCustomer"].ToString());
                            lInvoice.LCustomer.LNameCustomer     = lReader["NameCustomer"].ToString();
                            lInvoice.LCustomer.LLastNameCustomer = lReader["LastNameCustomer"].ToString();
                            lInvoice.LStatus.LIdStatus           = lReader["IdStatus"].ToString();
                            lInvoice.LObject.LIdObject           = Convert.ToInt32(lReader["IdObject"].ToString());
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lInvoice);
                }
                catch (Exception e)
                {
                    lInvoice = new BoInvoice {
                        LException = e.Message
                    };
                    if (e.InnerException != null)
                    {
                        lInvoice.LInnerException = e.InnerException.ToString();
                    }
                    lInvoice.LMessageDao = BoErrors.MsgErrorGetSql;
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lInvoice);
                }
            }
        }
Exemple #4
0
        public List <BoCashRegister> Dao_getListLastCashRegister()
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                var lListCashRegister = new List <BoCashRegister>();
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetAllItemsCashRegister",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    var lReader = lCommand.ExecuteReader();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            var lCashRegister = new BoCashRegister
                            {
                                LCreationDate     = Convert.ToDateTime(lReader["CreationDate"].ToString()),
                                LModificationDate = Convert.ToDateTime(lReader["ModificationDate"].ToString()),
                                LValue            = Convert.ToDecimal(lReader["Value"].ToString()),
                                LDescription      = lReader["Description"].ToString(),
                                LIdCash           = Convert.ToInt32(lReader["IdCash"].ToString()),
                                LIdCashRegister   = Convert.ToInt32(lReader["IdCashRegister"].ToString()),
                                LIsInput          = Convert.ToBoolean(lReader["IsInput"].ToString())
                            };
                            lListCashRegister.Add(lCashRegister);
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lListCashRegister);
                }
                catch (Exception e)
                {
                    lListCashRegister = new List <BoCashRegister>();
                    var lCash = new BoCashRegister {
                        LException = e.Message, LMessageDao = BoErrors.MsgErrorGetSql
                    };
                    if (e.InnerException != null)
                    {
                        lCash.LInnerException = e.InnerException.ToString();
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    lListCashRegister.Add(lCash);
                    return(lListCashRegister);
                }
            }
        }
Exemple #5
0
        public List <BoDashBoard> Dao_getProductSellToday()
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_dsbProductSellToday",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    var lReader        = lCommand.ExecuteReader();
                    var lListDashBoard = new List <BoDashBoard>();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            var lDashBoard = new BoDashBoard
                            {
                                Xstring = lReader["x"].ToString(),
                                Yint    = Convert.ToInt32(lReader["y"].ToString())
                            };
                            lListDashBoard.Add(lDashBoard);
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lListDashBoard);
                }
                catch (Exception e)
                {
                    var lListDashBoard = new List <BoDashBoard>();
                    var lDashBoard     = new BoDashBoard {
                        LException = e.Message
                    };
                    if (e.InnerException != null)
                    {
                        lDashBoard.LInnerException = e.InnerException.ToString();
                    }
                    lDashBoard.LMessageDao = BoErrors.MsgErrorGetSql;
                    lListDashBoard.Add(lDashBoard);
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lListDashBoard);
                }
            }
        }
Exemple #6
0
        public BoCashRegister Dao_getCashOutPut(int pIdCash)
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                var lCashOutPut = new BoCashRegister();
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetCashOutPut",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    lCommand.Parameters.Add(new SqlParameter("IdCash", pIdCash));
                    var lReader = lCommand.ExecuteReader();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            lCashOutPut.LCreationDate     = Convert.ToDateTime(lReader["CreationDate"].ToString());
                            lCashOutPut.LModificationDate = Convert.ToDateTime(lReader["ModificationDate"].ToString());
                            lCashOutPut.LValue            = Convert.ToDecimal(lReader["ValueOutPut"].ToString());
                            lCashOutPut.LDescription      = lReader["Descriptions"].ToString();
                            lCashOutPut.LIdCash           = Convert.ToInt32(lReader["IdCashOutPut"].ToString());
                            lCashOutPut.LIsInput          = true;
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lCashOutPut);
                }
                catch (Exception e)
                {
                    lCashOutPut = new BoCashRegister {
                        LException = e.Message, LMessageDao = BoErrors.MsgErrorGetSql
                    };
                    if (e.InnerException != null)
                    {
                        lCashOutPut.LInnerException = e.InnerException.ToString();
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lCashOutPut);
                }
            }
        }
        public List <BoCustomer> Dao_getListAllCustomer()
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetListAllCustomer",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    var lReader       = lCommand.ExecuteReader();
                    var oListCustomer = new List <BoCustomer>();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            var oCustomer = new BoCustomer
                            {
                                LStatus = new BoStatus
                                {
                                    LIdStatus = lReader["IdStatus"].ToString(),
                                    LDsEstado = lReader["DsEstado"].ToString()
                                },
                                LObject = new BoObject
                                {
                                    LIdObject   = Convert.ToInt32(lReader["IdObject"].ToString()),
                                    LNameObject = lReader["NameObject"].ToString()
                                },
                                LTypeIdentification =
                                    new BoTypeIdentification
                                {
                                    LIdTypeIdentification =
                                        Convert.ToInt32(lReader["IdTypeIdentification"].ToString()),
                                    LTypeIdentification = lReader["TypeIdentification"].ToString()
                                },
                                LIdCustomer       = Convert.ToInt32(lReader["IdCustomer"].ToString()),
                                LNoIdentification = lReader["NoIdentification"].ToString(),
                                LNameCustomer     = lReader["NameCustomer"].ToString(),
                                LLastNameCustomer = lReader["LastNameCustomer"].ToString(),
                                LCreationDate     =
                                    Convert.ToDateTime(lReader["CreationDate"].ToString() == ""
                                        ? new DateTime().ToString(CultureInfo.InvariantCulture)
                                        : lReader["CreationDate"].ToString()),
                                LModificationDate =
                                    Convert.ToDateTime(lReader["ModificationDate"].ToString() == ""
                                        ? new DateTime().ToString(CultureInfo.InvariantCulture)
                                        : lReader["ModificationDate"].ToString())
                            };
                            oListCustomer.Add(oCustomer);
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(oListCustomer);
                }
                catch (Exception e)
                {
                    var oListCustomer = new List <BoCustomer>();
                    var oCustomer     = new BoCustomer {
                        LException = e.Message
                    };
                    if (e.InnerException != null)
                    {
                        oCustomer.LInnerException = e.InnerException.ToString();
                    }
                    oCustomer.LMessageDao = BoErrors.MsgErrorGetSql;
                    oListCustomer.Add(oCustomer);
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(oListCustomer);
                }
            }
        }
        public BoProduct Dao_getProductByCode(string pCdProduct)
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                var lProduct = new BoProduct();
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetProductByCode",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    lCommand.Parameters.Add(new SqlParameter("CdProduct", pCdProduct));

                    var lReader = lCommand.ExecuteReader();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            lProduct.LIdProduct    = Convert.ToInt32(lReader["IdProduct"].ToString());
                            lProduct.LNameProduct  = lReader["NameProduct"].ToString();
                            lProduct.LCdProduct    = lReader["CdProduct"].ToString();
                            lProduct.LCreationDate = Convert.ToDateTime(lReader["CreationDate"].ToString());
                            lProduct.LUnit         = new BoUnit {
                                LIdUnit = Convert.ToInt32(lReader["IdUnit"].ToString())
                            };
                            lProduct.LValue    = Convert.ToDecimal(lReader["Price"].ToString());
                            lProduct.LSupplier = new BoSupplier
                            {
                                LIdSupplier = Convert.ToInt32(lReader["IdSupplier"].ToString())
                            };
                            lProduct.LValueSupplier = Convert.ToDecimal(lReader["PriceSupplier"].ToString());
                            lProduct.LStatus        = new BoStatus
                            {
                                LIdStatus = lReader["IdStatus"].ToString(),
                                LDsEstado = lReader["DsEstado"].ToString()
                            };
                            lProduct.LObject = new BoObject
                            {
                                LIdObject   = Convert.ToInt32(lReader["IdObject"].ToString()),
                                LNameObject = lReader["NameObject"].ToString()
                            };
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lProduct);
                }
                catch (Exception e)
                {
                    lProduct = new BoProduct {
                        LException = e.Message, LMessageDao = BoErrors.MsgErrorGetSql
                    };
                    if (e.InnerException != null)
                    {
                        lProduct.LInnerException = e.InnerException.ToString();
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lProduct);
                }
            }
        }