Example #1
0
        public void AddModifyRawMaterialDistributionItem(ItemQty itm)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("RawMaterialDistributionItemsLog", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ItemId", itm.ItemId);
                    cmd.Parameters.AddWithValue("@RawMaterialDisID", itm.RawMaterialDisId);
                    cmd.Parameters.AddWithValue("@rawMaterialId", itm.RawMaterialId);
                    cmd.Parameters.AddWithValue("@Qty", itm.Qty);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            //  return rv;
        }
Example #2
0
        public ReturnValues ShopKeeperAcceptApproveSendToShop(AdminApprove adap)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("ShopKeeperAcceptsFinishProductToShop", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserId", adap.UserId);
                    cmd.Parameters.AddWithValue("@BusinessId", adap.BusinessId);
                    cmd.Parameters.AddWithValue("@ItemApprovalId", adap.ItemApprovalId);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 100);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("We are catching an exception");
                        CommonUtilityClass.ExceptionLog(ex);
                        Console.WriteLine(ex.Message);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
        public int CheckLoginCredentials(UserData ld)
        {
            int n = 0;

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("CheckCredentialsLogin", conn))
                {
                    // @businessid = 1,@userid = 1,@lastpassword = '',@returnvalue = 1
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@userid", ld.UserID);
                    cmd.Parameters.AddWithValue("@businessid", ld.businessid);
                    cmd.Parameters.AddWithValue("@lastpassword", ld.lastUpdatePassword);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;

                    try
                    {
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                n = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(n);
        }
Example #4
0
        public ReturnValues AddRemoveSellProductQty(AddRemoveQty pr)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("AddRemoveProductQty", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@productId", pr.productId);
                    cmd.Parameters.AddWithValue("@userid", pr.userId);
                    cmd.Parameters.AddWithValue("@businessid", pr.businessId);
                    cmd.Parameters.AddWithValue("@addRemove", pr.ActionType);
                    cmd.Parameters.AddWithValue("@Qty", pr.Qty);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
                return(rv);
            }
        }
        public string GenerateUserToken(int userid, int businessid)
        {
            string tokenString = ce.GenerateRandomeStrings(20);
            string returnToken = "";

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("GenerateToken", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@token", tokenString);
                    cmd.Parameters.AddWithValue("@userId", userid);
                    cmd.Parameters.AddWithValue("@businessId", businessid);
                    cmd.Parameters.Add("@returnvalue", System.Data.SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;

                    try
                    {
                        cmd.ExecuteNonQuery();
                        if (Convert.ToInt32(cmd.Parameters["@returnvalue"].Value) == 1)
                        {
                            returnToken = tokenString;// ce.Encrypt(tokenString, CommonUtilityClass.apiEncryptKey);
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(returnToken);
        }
        public ReturnValues RegisterBusiness(BizRegModel bzm)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("RegisterBusinessAccount", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessname", bzm.businessName);
                    cmd.Parameters.AddWithValue("@businessAddress", bzm.businessAddress);
                    cmd.Parameters.AddWithValue("@fullname", bzm.fullname);
                    cmd.Parameters.AddWithValue("@email", bzm.email);
                    cmd.Parameters.AddWithValue("@phone", bzm.phone);
                    cmd.Parameters.AddWithValue("@password", bzm.password);
                    cmd.Parameters.Add("@returnvalue", System.Data.SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
        public ReturnValues ChangePassword(ChangePassword cp)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("ChangePassword", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", cp.businessid);
                    cmd.Parameters.AddWithValue("@userid", cp.UserID);
                    cmd.Parameters.AddWithValue("@oldpass", cp.OldPassword);
                    cmd.Parameters.AddWithValue("@newpass", cp.NewPassword);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
Example #8
0
        public ReturnValues CreateEditStore(ShopModel sm)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("CreateNewStore", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@StoreId", sm.StoreId);
                    cmd.Parameters.AddWithValue("@userId", sm.UserId);
                    cmd.Parameters.AddWithValue("@businessId", sm.BusinessId);
                    cmd.Parameters.AddWithValue("@StoreName", sm.StoreName);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 100);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
                return(rv);
            }
        }
Example #9
0
        public void AddModifyRawMaterialForFinishedProductsItems(ProductRawMaterial itm)
        {
            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("AddFinishedProductRawMaterials", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", itm.businessId);
                    cmd.Parameters.AddWithValue("@productID", itm.productId);
                    cmd.Parameters.AddWithValue("@rawMaterialID", itm.rawMaterialID);
                    cmd.Parameters.AddWithValue("@rawMaterialQty", itm.rawMaterialQty);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();

                        /*  rv.StatusCode = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                         * rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value); */
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);

                        /*    rv.StatusCode = 2000;
                         *  rv.StatusMessage = "An Error Occured"; */
                    }
                }
            }
        }
Example #10
0
        public List <PushedProductToStore> GetAllFinishedProductSentToShop(int businessid, int userid, int type)
        {
            List <PushedProductToStore> prl = new List <PushedProductToStore>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("getAllProductPushedToShop", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", businessid);
                    cmd.Parameters.AddWithValue("@userid", userid);
                    cmd.Parameters.AddWithValue("@type", type);
                    try
                    {
                        PushedProductToStore _prl;
                        SqlDataReader        reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _prl = new PushedProductToStore
                                {
                                    ProductId   = Convert.ToInt32(reader["ProductId"]),
                                    ProductName = reader["ProductName"] is DBNull ? null : (String)reader["ProductName"],
                                    Qty         = Convert.ToDecimal(reader["Qty"]),
                                    StoreId     = Convert.ToInt32(reader["StoreId"]),
                                    StoreName   = reader["StoreName"] is DBNull ? null : (String)reader["StoreName"],
                                    ActionType  = reader["ActionType"] is DBNull ? null : (String)reader["ActionType"],

                                    ProductionManagerId  = Convert.ToInt32(reader["ProductionManagerId"]),
                                    ProductionMangerName = reader["ProductionMangerName"] is DBNull ? null : (String)reader["ProductionMangerName"],
                                    AdminId                = Convert.ToInt32(reader["AdminId"]),
                                    AdminWhoApproved       = reader["AdminWhoApproved"] is DBNull ? null : (String)reader["AdminWhoApproved"],
                                    StoreManagerId         = Convert.ToInt32(reader["StoreManagerId"]),
                                    StoreManagerAssignTo   = reader["StoreManagerAssignTo"] is DBNull ? null : (String)reader["StoreManagerAssignTo"],
                                    StoreManagerAcceptDate = string.IsNullOrEmpty(reader["StoreManagerAcceptDate"].ToString()) ? (DateTime?)null : DateTime.Parse(reader["StoreManagerAcceptDate"].ToString()),
                                    StoreManagerAccept     = Convert.ToInt32(reader["StoreManagerAccept"]),
                                    YesAsAdmin             = Convert.ToInt32(reader["YesAsAdmin"]),
                                };

                                prl.Add(_prl);
                            }
                        }
                        else
                        {
                            prl = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(prl);
        }
Example #11
0
        public List <RawDisbursement> getRawMaterialDistributionTicket(int businessid)
        {
            List <RawDisbursement> rd = new List <RawDisbursement>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("getRawMaterialDistributionTicket", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", businessid);
                    try
                    {
                        RawDisbursement _sm    = new RawDisbursement();
                        SqlDataReader   reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _sm = new RawDisbursement
                                {
                                    DistributId              = Convert.ToInt32(reader["DistributId"]),
                                    BusinessId               = Convert.ToInt32(reader["BusinessId"]),
                                    UserId                   = Convert.ToInt32(reader["UserId"]),
                                    CreatedBy                = reader["createdUser"] is DBNull ? null : (String)reader["createdUser"],
                                    createddate              = Convert.ToDateTime(reader["createddate"]),
                                    ProductManagerId         = Convert.ToInt32(reader["ProductManagerId"]),
                                    productManagerName       = reader["productmanager"] is DBNull ? null : (String)reader["productmanager"],
                                    productmanagerAccept     = Convert.ToInt32(reader["productManagerAccept"]),
                                    productManagerAcceptDate = reader["productManagerAcceptDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(reader["productManagerAcceptDate"]),
                                    AdminApprove             = Convert.ToInt32(reader["AdminApprove"]),
                                    AdminName                = reader["AdminApproveName"] is DBNull ? null : (String)reader["AdminApproveName"],
                                    AdminApproveDate         = reader["AdminApproveDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(reader["AdminApproveDate"]),
                                    Items = getRawMaterialDistributionTicketItems(Convert.ToInt32(reader["DistributId"])),
                                };

                                rd.Add(_sm);
                            }
                        }
                        else
                        {
                            rd = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }

            return(rd);
        }
Example #12
0
 public static SqlConnection getConnection()
 {
     try
     {
         con = new SqlConnection(connectionstring());
         con.Open();
     }
     catch (Exception ex)
     {
         CommonUtilityClass.ExceptionLog(ex);
     }
     return(con);
 }
Example #13
0
        public List <StoreModel> GetAllMaterials(int businessid)
        {
            List <StoreModel> sm = new List <StoreModel>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("getBusinessRawMaterials", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", businessid);
                    try
                    {
                        StoreModel    _sm    = new StoreModel();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _sm = new StoreModel {
                                    id               = Convert.ToInt32(reader["id"]),
                                    BusinessId       = Convert.ToInt32(reader["businessID"]),
                                    userid           = Convert.ToInt32(reader["createdBy"]),
                                    createdByName    = reader["createdByName"] is DBNull ? null : (String)reader["createdByName"],
                                    MaterialName     = reader["MaterialName"] is DBNull ? null : (String)reader["MaterialName"],
                                    Qty              = Convert.ToDecimal(reader["Qty"]),
                                    CostPrice        = Convert.ToDecimal(reader["CostPrice"]),
                                    SellingPrice     = Convert.ToDecimal(reader["SellingPrice"]),
                                    MeasureId        = Convert.ToInt32(reader["measureID"]),
                                    measurementTitle = reader["measurement"] is DBNull ? null : (String)reader["measurement"],
                                    active           = Convert.ToInt32(reader["active"]),
                                    QtyAlert         = Convert.ToDecimal(reader["QtyAlert"])
                                };

                                sm.Add(_sm);
                            }
                        }
                        else
                        {
                            sm = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }

            return(sm);
        }
        public List <UserData> AllBusinessStaffList(int businessid)
        {
            List <UserData> AllStaff = new List <UserData>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("SelectBusinessStaff", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", businessid);
                    try
                    {
                        UserData      ud     = new UserData();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ud = new UserData
                                {
                                    businessid         = Convert.ToInt32(reader["businessID"]),
                                    UserID             = Convert.ToInt32(reader["id"]),
                                    email              = reader["email"] is DBNull ? null : (String)reader["email"],
                                    phone              = reader["phoneNumber"] is DBNull ? null : (String)reader["phoneNumber"],
                                    departmentID       = Convert.ToInt32(reader["DepartmentID"]),
                                    levelID            = Convert.ToInt32(reader["levelID"]),
                                    fullname           = reader["fullname"] is DBNull ? null : (String)reader["fullname"],
                                    active             = Convert.ToInt32(reader["active"]),
                                    lastUpdatePassword = Convert.ToDateTime(reader["lastUpdatePassword"]),
                                    loggedIn           = Convert.ToInt32(reader["loggedIn"]),
                                };
                                AllStaff.Add(ud);
                            }
                        }
                        else
                        {
                            ud = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(AllStaff);
        }
Example #15
0
        public List <productsList> GetProductsLists(int BusinessId)
        {
            List <productsList> prl = new List <productsList>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("GetAllProducts", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessId", BusinessId);
                    try
                    {
                        productsList  _prl   = new productsList();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _prl = new productsList
                                {
                                    ProductId         = Convert.ToInt32(reader["id"]),
                                    ProductName       = reader["ProductName"] is DBNull ? null : (String)reader["ProductName"],
                                    Code              = reader["Code"] is DBNull ? null : (String)reader["Code"],
                                    SellingPercentage = Convert.ToDecimal(reader["SellingPercentage"]),
                                    Qty = Convert.ToDecimal(reader["Qty"]),
                                    CostOfRawMaterial   = Convert.ToDecimal(reader["CostOfRawMaterial"]),
                                    LastSellingPrice    = Convert.ToDecimal(reader["LastSellingPrice"]),
                                    ProductRawMaterials = GetProductsRawMaterial(Convert.ToInt32(reader["id"]), BusinessId)
                                };

                                prl.Add(_prl);
                            }
                        }
                        else
                        {
                            prl = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(prl);
        }
        public UserData Login(LoginData ld)
        {
            UserData ud = new UserData();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("LoginUsers", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@email", ld.email);
                    cmd.Parameters.AddWithValue("@password", ld.password);
                    try
                    {
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ud = new UserData {
                                    businessid         = Convert.ToInt32(reader["businessID"]),
                                    UserID             = Convert.ToInt32(reader["id"]),
                                    email              = reader["email"] is DBNull ? null : (String)reader["email"],
                                    phone              = reader["phoneNumber"] is DBNull ? null : (String)reader["phoneNumber"],
                                    departmentID       = Convert.ToInt32(reader["DepartmentID"]),
                                    levelID            = Convert.ToInt32(reader["levelID"]),
                                    fullname           = reader["fullname"] is DBNull ? null : (String)reader["fullname"],
                                    active             = Convert.ToInt32(reader["active"]),
                                    lastUpdatePassword = Convert.ToDateTime(reader["lastUpdatePassword"]),
                                    loggedIn           = Convert.ToInt32(reader["loggedIn"]),
                                    token              = GenerateUserToken(Convert.ToInt32(reader["id"]), Convert.ToInt32(reader["businessID"]))
                                };
                            }
                        }
                        else
                        {
                            ud = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(ud);
        }
Example #17
0
        public List <ItemQty> getRawMaterialDistributionTicketItems(int TicketID)
        {
            List <ItemQty> sm = new List <ItemQty>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("getRawMaterialDistributionTicketItems", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ticketID", TicketID);
                    try
                    {
                        ItemQty       _sm    = new ItemQty();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _sm = new ItemQty
                                {
                                    ItemId           = Convert.ToInt32(reader["ItemId"]),
                                    RawMaterialDisId = Convert.ToInt32(reader["RawMaterialDisID"]),
                                    RawMaterialId    = Convert.ToInt32(reader["RawMaterialId"]),
                                    MaterialName     = reader["MaterialName"] is DBNull ? null : (String)reader["MaterialName"],
                                    measurement      = reader["measurement"] is DBNull ? null : (String)reader["measurement"],
                                    Qty = Convert.ToInt32(reader["Qty"])
                                };

                                sm.Add(_sm);
                            }
                        }
                        else
                        {
                            sm = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }

            return(sm);
        }
        public static ReturnValuesBool ValidateToken(string token, int userid, int businessid)
        {
            ReturnValuesBool rvb = new ReturnValuesBool();

            rvb.StatusFlag = false;
            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("ValidateToken", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@token", token);
                    cmd.Parameters.AddWithValue("@businessId", businessid);
                    cmd.Parameters.AddWithValue("@userId", userid);
                    cmd.Parameters.Add("@returnvalue", System.Data.SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;

                    try
                    {
                        cmd.ExecuteNonQuery();
                        rvb.StatusCode = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        if (rvb.StatusCode == 1)
                        {
                            rvb.StatusFlag = true;
                        }
                        else
                        {
                            if (rvb.StatusCode == 2)
                            {
                                rvb.StatusMessage = "Token has expired";
                            }
                            if (rvb.StatusCode == 0)
                            {
                                rvb.StatusMessage = "Another user loggedIn with your account";
                            }
                            rvb.StatusFlag = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(rvb);
        }
Example #19
0
        public ReturnValues CreateEditFinishRawMaterial(ProductModel pm)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("CreateFinishedProducts", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@mainProductId", pm.ProductId);
                    cmd.Parameters.AddWithValue("@ProductName", pm.ProductName);
                    cmd.Parameters.AddWithValue("@BusinessId", pm.BusinessId);
                    cmd.Parameters.AddWithValue("@userId", pm.UserId);
                    cmd.Parameters.AddWithValue("@categoryID", pm.CategoryId);
                    cmd.Parameters.AddWithValue("@SellingPrice", pm.SellingPrice);
                    cmd.Parameters.AddWithValue("@Code", pm.Code);
                    cmd.Parameters.AddWithValue("@active", 1);
                    cmd.Parameters.AddWithValue("@SellingPercentage", pm.SellingPercentage);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@productID", SqlDbType.Int);
                    cmd.Parameters["@productID"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        int myProductId = Convert.ToInt32(cmd.Parameters["@productID"].Value);
                        rv.StatusCode = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        this.AddModifyRawMaterialForFinishedProducts(myProductId, pm.BusinessId, pm.productRaws);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        Console.WriteLine(ex.Message);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
Example #20
0
        public List <ShopModel> GetStoreLists(int BusinessId)
        {
            List <ShopModel> prl = new List <ShopModel>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("GetAllStores", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessId", BusinessId);
                    try
                    {
                        ShopModel     _prl   = new ShopModel();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _prl = new ShopModel
                                {
                                    StoreId     = Convert.ToInt32(reader["StoreId"]),
                                    BusinessId  = Convert.ToInt32(reader["BusinessId"]),
                                    UserId      = Convert.ToInt32(reader["adminId"]),
                                    StoreName   = reader["StoreName"] is DBNull ? null : (String)reader["StoreName"],
                                    CreatedBy   = reader["fullname"] is DBNull ? null : (String)reader["fullname"],
                                    Createddate = string.IsNullOrEmpty(reader["Createddate"].ToString()) ? (DateTime?)null : DateTime.Parse(reader["Createddate"].ToString()),
                                };

                                prl.Add(_prl);
                            }
                        }
                        else
                        {
                            prl = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(prl);
        }
Example #21
0
        public List <ProductRawMaterial> GetProductsRawMaterial(int proid, int busId)
        {
            List <ProductRawMaterial> prl = new List <ProductRawMaterial>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("getRawMaterialByProductId", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@productId", proid);
                    try
                    {
                        ProductRawMaterial _prl   = new ProductRawMaterial();
                        SqlDataReader      reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _prl = new ProductRawMaterial
                                {
                                    productId       = proid,
                                    businessId      = busId,
                                    rawMaterialID   = Convert.ToInt32(reader["rawMaterialID"]),
                                    rawMaterialName = reader["MaterialName"] is DBNull ? null : (String)reader["MaterialName"],
                                    rawMaterialQty  = Convert.ToDecimal(reader["rawMaterialQty"]),
                                };

                                prl.Add(_prl);
                            }
                        }
                        else
                        {
                            prl = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }
            return(prl);
        }
Example #22
0
        public ReturnValues SendFinishProductToShop(FinishedProductToShop fp)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("SendFinishedProductToStore", conn))//call Stored Procedure
                {
                    //fp.ActionType --- 1 -> Add to Store, 2-> Moved from store, 3-> sold from store

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@BusinessId", fp.BusinessId);
                    cmd.Parameters.AddWithValue("@StoreId", fp.StoreId);
                    cmd.Parameters.AddWithValue("@ProductId", fp.ProductId);
                    cmd.Parameters.AddWithValue("@ActionQty", fp.ActionQty);
                    cmd.Parameters.AddWithValue("@ActionType", "Add To Store");
                    cmd.Parameters.AddWithValue("@ProductionManagerId", fp.ProductionManagerId);
                    cmd.Parameters.AddWithValue("@StoreManagerId", fp.StoreManagerId);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("We are catching an exception");
                        CommonUtilityClass.ExceptionLog(ex);
                        Console.WriteLine(ex.Message);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
Example #23
0
        public ReturnValues CreateModifyRawMaterial(StoreModel str)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("RegisterModifyRawMaterial", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", str.id);
                    cmd.Parameters.AddWithValue("@userid", str.userid);
                    cmd.Parameters.AddWithValue("@businessid", str.BusinessId);
                    cmd.Parameters.AddWithValue("@materialName", str.MaterialName);
                    cmd.Parameters.AddWithValue("@costPrice", str.CostPrice);
                    cmd.Parameters.AddWithValue("@sellingPrice", str.SellingPrice);
                    cmd.Parameters.AddWithValue("@measureID", str.MeasureId);
                    cmd.Parameters.AddWithValue("@active", str.active);
                    cmd.Parameters.AddWithValue("@qtyAlert", str.QtyAlert);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
        public ReturnValues RegisterBusinessStaff(UserData usd)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("RegisterBusinessStaff", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", usd.businessid);
                    cmd.Parameters.AddWithValue("@userid", usd.UserID);
                    cmd.Parameters.AddWithValue("@fullname", usd.fullname);
                    cmd.Parameters.AddWithValue("@email", usd.email);
                    cmd.Parameters.AddWithValue("@phone", usd.phone);
                    cmd.Parameters.AddWithValue("@departmentID", usd.departmentID);
                    cmd.Parameters.AddWithValue("@levelId", usd.levelID);
                    cmd.Parameters.AddWithValue("@password", usd.password);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
Example #25
0
        public ReturnValues AddRemove(StoreMaterial sm)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("AddRemoveSellRawMaterial", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@rawMaterialID", sm.RawMaterialId);
                    cmd.Parameters.AddWithValue("@userid", sm.UserId);
                    cmd.Parameters.AddWithValue("@businessid", sm.BusinessId);
                    cmd.Parameters.AddWithValue("@addRemove", sm.AddRemove);
                    cmd.Parameters.AddWithValue("@Qty", sm.Qty);
                    cmd.Parameters.AddWithValue("@costPrice", sm.costPrice);
                    cmd.Parameters.AddWithValue("@sellingPrice", sm.sellingPrice);
                    cmd.Parameters.AddWithValue("@updatePrice", sm.updatePrice);

                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();
                        rv.StatusCode    = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }
Example #26
0
        public ReturnValues AddModifyRawMaterialDistribution(RawDisbursement rd)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("CreateModifyRawMaterialDistribution", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@DistributId", rd.DistributId);
                    cmd.Parameters.AddWithValue("@userid", rd.UserId);
                    cmd.Parameters.AddWithValue("@businessid", rd.BusinessId);
                    cmd.Parameters.AddWithValue("@ProductManagerId", rd.ProductManagerId);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();


                        rv.StatusCode = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        this.AddModifyRawMaterialDistribution(rv.StatusCode, rd.Items);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                        rv.StatusCode    = 1;
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }