Пример #1
0
        public BoOrder Dao_getOrder(int pIdOrder)
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetOrder",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    lCommand.Parameters.Add(new SqlParameter("IdOrder", pIdOrder));

                    var lReader = lCommand.ExecuteReader();
                    var lOrder  = new BoOrder();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            lOrder.LStatus   = new BoStatus();
                            lOrder.LObject   = new BoObject();
                            lOrder.LCustomer = new BoCustomer
                            {
                                LIdCustomer       = Convert.ToInt32(lReader["IdCustomer"].ToString()),
                                LNameCustomer     = lReader["NameCustomer"].ToString(),
                                LLastNameCustomer = lReader["LastNameCustomer"].ToString()
                            };
                            lOrder.LIdOrder   = Convert.ToInt32(lReader["IdOrder"].ToString());
                            lOrder.LInventory = new BoInventory
                            {
                                LIdInventory   = Convert.ToInt32(lReader["IdInventory"].ToString()),
                                LNameInventory = lReader["NameInventory"].ToString()
                            };
                            lOrder.LCreationDate     = Convert.ToDateTime(lReader["CreationDate"].ToString());
                            lOrder.LStatus.LIdStatus = lReader["IdStatus"].ToString();
                            lOrder.LObject.LIdObject = Convert.ToInt32(lReader["IdObject"].ToString());
                        }
                    }
                    Dao_CloseSqlconnection(lConex);
                    return(lOrder);
                }
                catch (Exception e)
                {
                    var lOrder = new BoOrder {
                        LException = e.Message
                    };
                    if (e.InnerException != null)
                    {
                        lOrder.LInnerException = e.InnerException.ToString();
                    }
                    lOrder.LMessageDao = BoErrors.MsgErrorGetSql;
                    Dao_CloseSqlconnection(lConex);
                    return(lOrder);
                }
            }
        }
Пример #2
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);
                }
            }
        }
Пример #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);
                }
            }
        }
Пример #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);
                }
            }
        }
Пример #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);
                }
            }
        }
Пример #8
0
        public List <BoInvoice> Dao_getInvoiceListAll(int pIdCustomer)
        {
            SqlConnection lConex = new SqlConnection();

            using (lConex = DaoUtilsLib.Dao_SqlConnection(lConex))
            {
                var lListInvoice = new List <BoInvoice>();
                try
                {
                    var lCommand = new SqlCommand
                    {
                        CommandText    = "spr_GetListInvoiceAll",
                        CommandTimeout = 30,
                        CommandType    = CommandType.StoredProcedure,
                        Connection     = lConex
                    };
                    lCommand.Parameters.Add(new SqlParameter("IdCustomer", pIdCustomer));
                    var lReader = lCommand.ExecuteReader();
                    if (lReader.HasRows)
                    {
                        while (lReader.Read())
                        {
                            var oInvoice = new BoInvoice
                            {
                                LStatus = new BoStatus {
                                    LIdStatus = lReader["IdStatus"].ToString()
                                },
                                LObject = new BoObject {
                                    LIdObject = Convert.ToInt32(lReader["IdObject"].ToString())
                                },
                                LCustomer =
                                    new BoCustomer
                                {
                                    LIdCustomer       = Convert.ToInt32(lReader["IdCustomer"].ToString()),
                                    LNameCustomer     = lReader["NameCustomer"].ToString(),
                                    LLastNameCustomer = lReader["LastNameCustomer"].ToString()
                                },
                                LIdInvoice    = Convert.ToInt32(lReader["IdInvoice"].ToString()),
                                LCdInvoice    = lReader["CdInvoice"].ToString(),
                                LCreationDate = Convert.ToDateTime(lReader["CreationDate"].ToString())
                            };
                            lListInvoice.Add(oInvoice);
                        }
                    }
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    return(lListInvoice);
                }
                catch (Exception e)
                {
                    lListInvoice = new List <BoInvoice>();
                    var lInvoice = new BoInvoice {
                        LException = e.Message
                    };
                    if (e.InnerException != null)
                    {
                        lInvoice.LInnerException = e.InnerException.ToString();
                    }
                    lInvoice.LMessageDao = BoErrors.MsgErrorGetSql;
                    DaoUtilsLib.Dao_CloseSqlconnection(lConex);
                    lListInvoice.Add(lInvoice);
                    return(lListInvoice);
                }
            }
        }
        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);
                }
            }
        }